You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/I.getting-started/install.mec
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ Download and Install Mech
6
6
7
7
The easiest way to install Mech is to use the installer provided for your platform. The installer includes the `mech` command-line tool, which is a standalone executable that includes everything you need to get started with Mech.
@@ -207,32 +207,38 @@ Because Mech has a focus on literate programming, comment have less of an emphas
207
207
208
208
Therefore, comments are primarily used for writing notes inline with the code that cannot be broken out into a paragraph. For example, to make a note within a state machine definition.
209
209
210
-
**Examples:**
210
+
(3.3.1) Examples
211
211
212
212
Here are some ways to write a comment in Mech:
213
213
214
214
```
215
-
-- Single line comment.
216
-
// Also a single line comment.
215
+
-- Comment prefix with --
216
+
// Comment prefixed with //
217
+
-- Supports formatting like **bold**, __underline__, `inline code`, and [links](https://example.com).
217
218
x := 1 -- Comment after an expression
218
219
```
219
220
220
221
When parsed and rendered, these become:
221
222
222
-
```mech-comment
223
+
```mech:disabled
223
224
-- Comment prefix with --
224
225
// Comment prefixed with //
226
+
-- Supports formatting like **bold**, __underline__, `inline code`, and [links](https://example.com).
225
227
x := 1 -- Comment after an expression
226
228
```
227
229
230
+
One special ability comments have is they can be used to print out the evaluation of a Mech code statement.
231
+
232
+
qq := 10 * 20 -- The value of qq is {qq}
233
+
228
234
(3.4) Keywords
229
235
230
236
There are only two keywords in Mech: `true` and `false`. Because Mech is designed to be used by non-English speakers, the syntax allows for an alternative representation, which can be used in place of the English keywords.
231
237
232
-
| Keyword | Alternative |
233
-
|---------|-------------|
234
-
| true | ✓ |
235
-
| false | ✗ |
238
+
| Keyword | Alternative |
239
+
|-----------|-------------|
240
+
| `true` | `✓` |
241
+
| `false` | `✗` |
236
242
237
243
This allows users to write code in their native language without the need to learn English keywords.
238
244
@@ -281,12 +287,13 @@ Mech supports several types of literals, which are used to represent values in t
281
287
- `f32` - 32-bit floating-point number
282
288
- `f64` - 64-bit floating-point number
283
289
- **Imaginary** - Represent imaginary components of complex numbers.
284
-
- **String** - A sequence of UTF-8 characters representing text.
285
-
- `string` - A sequence of characters enclosed in double quotes.
286
-
- **Boolean** - Represents logical truth values.
290
+
- **String**
291
+
- `string` - A sequence of UTF-8 characters representing text.
292
+
- **Boolean**
293
+
- `bool` - Represents logical truth values.
287
294
- **Atom** - A symbolic constant, often used for tags or enums.
288
-
- **Empty** - Represents an empty value, placeholder, or the absence of a value.
289
-
- **Kind** - A meta-type that categorizes types
295
+
- **Empty**
296
+
- `_` - Represents an empty value, placeholder, or the absence of a value.
290
297
291
298
(4.1) Kinds
292
299
@@ -334,15 +341,12 @@ Kinds are used to specify the type of a literal or expression in Mech. Kinds are
334
341
335
342
**Examples:**
336
343
337
-
```
338
344
<_> -- Empty
339
345
<`A> -- Atom
340
346
<{A:B}> -- Map
341
-
<(A,B)=(C,D)> -- Function
342
347
<{A}> -- Set
343
348
<[A]> -- Matrix
344
349
<(A,B,C)> -- Tuple
345
-
```
346
350
347
351
(4.2) Numbers
348
352
@@ -364,7 +368,7 @@ An integer literal is a sequence of digits representing a whole number. Mech sup
364
368
- Octal: Prefixed with 0o, containing digits 0-7 (e.g., 0o755).
365
369
- Binary: Prefixed with 0b, containing only 0 and 1 (e.g., 0b1010).
366
370
367
-
**Examples:**
371
+
(4.2.1.1) Examples
368
372
369
373
42 -- decimal
370
374
0d42 -- decimal
@@ -373,13 +377,15 @@ An integer literal is a sequence of digits representing a whole number. Mech sup
373
377
0o12345670 -- octal
374
378
0b100110101 -- binary
375
379
380
+
(4.2.1.2) Kind
381
+
376
382
By default, Mech can represent integers in the following data types:
377
383
378
384
- Signed: `i8`, `i16`, `i32`, `i64`, `i128`
379
385
- Unsigned: `u8`, `u16`, `u32`, `u64`, `u128`
380
386
- Float: `f32`, `f64`
381
387
382
-
Unless specified or inferred, the default data type for integer literals is `f64`. This is different from many systems languages but consist with other languages like Python, JavaScript, and Ruby.
388
+
Unless specified or inferred, the default data type for integer literals is `f64`. This is different from many systems languages but consist with other languages like Matlab, Python, and Javascript.
383
389
384
390
(4.2.2) Fractional Numbers
385
391
@@ -404,7 +410,7 @@ A floating-point literal represents a real number, potentially with a fractional
404
410
- **Scientific notation**: A number followed by e or E, then an optional sign and exponent (e.g., `2.5e10`, `1e-3`)
405
411
- **Rational literals**: A fraction of two integers separated by `/` (e.g., `3/4`, `22/7`) — these may be evaluated as exact values or approximated depending on context.
406
412
407
-
**Examples:**
413
+
(4.2.2.1) Examples
408
414
409
415
3.14 -- decimal float
410
416
0.001 -- decimal float
@@ -657,9 +663,14 @@ A Set is defined using curly braces `{}` and contains a comma-separated list of
657
663
658
664
(5.2.4) Kind
659
665
660
-
```
661
-
<{u8}:3>
662
-
```
666
+
The kind of a set consists of:
667
+
668
+
- The kind of the elements
669
+
- The number of elements, which can be dynamic or fixed
670
+
671
+
<{u8}> -- Generic set of unsigned 8-bit integers
672
+
<{u8}:3> -- Set of 3 unsigned 8-bit integers
673
+
<{{i8}}> -- Set of sets of signed 8-bit integers
663
674
664
675
(5.3) Map
665
676
@@ -696,27 +707,30 @@ A Map is defined using curly braces `{}` and contains a set of key-value mapping
0 commit comments