Skip to content

Commit c452b25

Browse files
committed
Merge branch 'main' of https://gitlab.com/mech-lang/mech
2 parents cfc945c + bd3479c commit c452b25

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1451
-936
lines changed

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mech"
3-
version = "0.2.50"
3+
version = "0.2.51"
44
authors = ["Corey Montella <[email protected]>"]
55
description = "Mech is a reactive programming language for building robots, games, and animations."
66
documentation = "https://mech-lang.org/docs"
@@ -64,9 +64,9 @@ VectorD = []
6464
MatrixD = []
6565

6666
[dependencies]
67-
mech-core = "0.2.50"
68-
mech-syntax = "0.2.50"
69-
mech-interpreter = "0.2.50"
67+
mech-core = "0.2.51"
68+
mech-syntax = "0.2.51"
69+
mech-interpreter = "0.2.51"
7070

7171
clap = {version = "4.5.40", features = ["cargo"]}
7272
colored = "3.0.0"
@@ -124,13 +124,13 @@ mech-interpreter = { path = 'src/interpreter'}
124124
#mech-logic = { path = '../machines/logic' }
125125

126126
[patch.'https://gitlab.com/mech-lang/core']
127-
mech-core = { path = 'src/core', version = '0.2.50' }
127+
mech-core = { path = 'src/core', version = '0.2.51' }
128128

129129
[patch.'https://gitlab.com/mech-lang/syntax']
130-
mech-syntax = { path = 'src/syntax', version = '0.2.50' }
130+
mech-syntax = { path = 'src/syntax', version = '0.2.51' }
131131

132132
[patch.'https://gitlab.com/mech-lang/interpreter']
133-
mech-interpreter = { path = 'src/interpreter', version = '0.2.50' }
133+
mech-interpreter = { path = 'src/interpreter', version = '0.2.51' }
134134

135135
#[patch.'https://gitlab.com/mech-lang/wasm']
136136
#mech-wasm = { path = 'src/wasm', version = '0.2.44' }

docs/I.getting-started/install.mec

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ Download and Install Mech
66

77
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.
88

9-
- **Windows** - [x86-64](https://github.com/mech-lang/mech/releases/download/v0.2.49-beta/mech-installer-v0.2.49-beta-win-x86-64.exe)
9+
- **Windows** - [x86-64](https://github.com/mech-lang/mech/releases/download/v0.2.51-beta/mech-installer-v0.2.51-beta-win-x86-64.exe)
1010

1111
Right now, the installer is only available for Windows, but we are working on providing installers for other platforms in the future.
1212

1313

1414
(1.1) Desktop App
1515

16-
We're experimenting with a Tauri-based app for Mech as well, which is kind of like Electron but Rust's version; it uses the system's webview to render the UI, which makes it much more lightweight and efficient. Right now all it does is wrap the Mech REPL, and it works, but it's not clear if this is the right direction for the project. If you want to try it out, you can [download the Mech Tauri app for Windows](https://github.com/mech-lang/mech/releases/download/v0.2.49-beta/mech-app_0.2.49_x86-64-setup.exe).
16+
We're experimenting with a Tauri-based app for Mech as well, which is kind of like Electron but Rust's version; it uses the system's webview to render the UI, which makes it much more lightweight and efficient. Right now all it does is wrap the Mech REPL, and it works, but it's not clear if this is the right direction for the project. If you want to try it out, you can [download the Mech Tauri app for Windows](https://github.com/mech-lang/mech/releases/download/v0.2.51-beta/mech-app_0.2.51_x86-64-setup.exe).
1717

1818

1919
2. Binary
@@ -25,10 +25,10 @@ Precompiled binaries are available for the following platforms:
2525

2626
| OS | Architecture |
2727
| ---------- | ------------------------------------------------------------------------------------------------------------ |
28-
| **Wndows** | [x86-64](https://github.com/mech-lang/mech/releases/download/v0.2.49-beta/mech-v0.2.49-beta-win-x86-64.7z) |
29-
| **Linux** | [x86-64](https://github.com/mech-lang/mech/releases/download/v0.2.49-beta/mech-v0.2.49-beta-win-x86-64.7z) |
30-
| **macOS** | [aarch64](https://github.com/mech-lang/mech/releases/download/v0.2.49-beta/mech-v0.2.49-beta-mac-aarch64.zip) |
31-
| **Web** | [wasm](https://github.com/mech-lang/mech/releases/download/v0.2.49-beta/mech_wasm_bg.wasm.br) |
28+
| **Wndows** | [x86-64](https://github.com/mech-lang/mech/releases/download/v0.2.51-beta/mech-v0.2.51-beta-win-x86-64.7z) |
29+
| **Linux** | [x86-64](https://github.com/mech-lang/mech/releases/download/v0.2.51-beta/mech-v0.2.51-beta-win-x86-64.7z) |
30+
| **macOS** | [aarch64](https://github.com/mech-lang/mech/releases/download/v0.2.51-beta/mech-v0.2.51-beta-mac-aarch64.zip) |
31+
| **Web** | [wasm](https://github.com/mech-lang/mech/releases/download/v0.2.51-beta/mech_wasm_bg.wasm.br) |
3232

3333
You can find previous releases and release notes at [/mech-lang/mech/releases](https://github.com/mech-lang/mech/releases).
3434

docs/II.reference/table.mec

Lines changed: 117 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,158 @@
11
Table
22
===============================================================================
33

4-
A `Table` in Mech is a set of records, where each record corresponds to a row and each column has a name and kind. Tables provide structured, columnar data that is flexible and human-readable.
4+
A table in Mech is a set of records, where each record corresponds to a row and each column has a name and kind. Tables provide structured, columnar data that is flexible and human-readable.
55

66
1. Syntax
77
-------------------------------------------------------------------------------
88

9-
Tables are defined using curly braces `{}` with named columns and a vertical bar `|` to separate column headers from data rows.
9+
(1.1) Basic Syntax
1010

11-
```mech
12-
| x<f32> y<u8> |
13-
| 1.2 9 |
14-
| 1.3 8 |
15-
```
11+
Tables are defined using the pipe `|` character. Each column is defined with a name and a kind, which describes the type of data it holds.
1612

17-
This creates a table with two columns, `x` of kind `f32` and `y` of kind `u8`.
13+
```
14+
| x&ltf32&gt y&ltbool&gt |
15+
| 1.2 true |
16+
| 1.3 false |
17+
```
1818

19-
You can write tables inline using semicolons to separate rows:
19+
This creates a table with two columns, `x` of kind `f32` and `y` of kind `bool`:
2020

21-
```mech
22-
| x<f32> y<u8> |{ 1.2 9; 1.3 8 }
21+
```mech:disabled
22+
| x<f32> y<bool> |
23+
| 1.2 true |
24+
| 1.3 false |
2325
```
2426

25-
2. Heterogeneous Columns
26-
27-
---
27+
(1.2) Inline Syntax
2828

29-
The kind `_` indicates that a column may contain heterogeneous data:
29+
You can write tables inline as well:
3030

31-
```mech
32-
| x<_> y<_> |
33-
| 1.2 true|
34-
| "Hi" 8 |
31+
```
32+
| x&ltf32&gt y&ltbool&gt | 1.2 true | 1.3 false |
3533
```
3634

37-
Each cell in the column may hold a different type of value.
35+
(1.3) Fancy Syntax
3836

39-
3. Partial Rows
37+
The Mech REPL formats matrix output using fancy box drawing characters for better readability.
4038

41-
---
39+
```
40+
╭────────┬─────────╮
41+
│ x&ltf32&gt │ y&ltbool&gt │
42+
├────────┼─────────┤
43+
│ 1.2 │ true │
44+
│ 1.3 │ false │
45+
╰────────┴─────────╯
46+
```
4247

43-
You can omit values in certain rows using `_` to indicate a missing value:
48+
Mech can parse data formatted this way, allowing you to copy or pipe REPL output directly into a Mech program that expects a table. The above example evaluates to:
4449

45-
```mech
46-
| x<u8> y<string> z<[u8]:3> |
47-
| _ "a" [1;2;3] |
48-
| 4 "b" _ |
49-
| 7 _ [7;8;9] |
50+
```mech:disabled
51+
╭────────┬─────────╮
52+
│ x<u64> │ y<bool> │
53+
├────────┼─────────┤
54+
│ 1.2 │ true │
55+
│ 1.3 │ false │
56+
╰────────┴─────────╯
5057
```
5158

52-
4. Fancy Formatting
59+
Fancy tables can be formatted in a variety of ways:
5360

54-
---
61+
```
62+
╭────────┬────────╮
63+
│ x&ltu64&gt │ y&ltf32&gt │
64+
├────────┼────────┤
65+
│ 1 │ 2 │
66+
├────────┼────────┤
67+
│ 3 │ 4 │
68+
╰────────┴────────╯
69+
```
5570

56-
Tables can be displayed using a box-drawn format in the REPL for improved readability:
71+
This one has no horizontal lines between rows, making it more compact:
5772

5873
```
59-
╭────────────────────────────────╮
60-
│ x<u8> y<string> z<[u8]:1,3> │
61-
├───────┬──────────┬─────────────┤
62-
│ _ │ "a" │ [1,2,3,4] │
63-
├───────┼──────────┼─────────────┤
64-
│ 4 │ "b" │ _ │
65-
├───────┼──────────┼─────────────┤
66-
│ 7 │ _ │ [5,6,7,8] │
67-
╰───────┴──────────┴─────────────╯
74+
╭────────┬────────╮
75+
│ x&ltu64&gt │ y&ltf32&gt │
76+
│ 1 │ 2 │
77+
│ 3 │ 4 │
78+
╰────────┴────────╯
6879
```
6980

81+
2. Kind
82+
--------------------------------------------------------------------------------
83+
84+
A table's kind describes the names and kinds of the columns, as well as the number of rows in the table. For example:
85+
86+
<|x<u8> y<f32>|:3>
87+
88+
This represents a table with two columns, `x` of kind `u8` and `y` of kind `f32`, and 3 rows.
89+
90+
3. Construction
91+
-------------------------------------------------------------------------------
92+
93+
Tables can be constructed of vectors, matrices, or records.
94+
95+
(3.1) From vectors
96+
97+
(3.2) From a matrix
98+
99+
(3.3) From records
100+
101+
4. Accessing Elements
102+
-------------------------------------------------------------------------------
103+
104+
Consider the table:
105+
106+
a:=| x<f32> y<bool> |
107+
| 1.2 true |
108+
| 1.3 false |
109+
110+
(4.1) Access a Column
111+
112+
Use dot indexing to access columns. For example {{a.x;}}. The kind of the result is a column vector with elements of the column's kind. For instance, column `x` has kind `f32`, so the result of accessing that column is a column vector of kind `[f32]`, with the same number of rows as the table:
113+
114+
```mech
115+
a.x -- Select column `x`, which has kind `[f32]`
70116
```
71-
╭────────────────────────────────╮
72-
│ x<u8> y<string> z<[u8]:1,3> │
73-
├───────┬──────────┬─────────────┤
74-
│ _ │ "a" │ [1,2,3,4] │
75-
│ 4 │ "b" │ _ │
76-
│ 7 │ _ │ [5,6,7,8] │
77-
╰───────┴──────────┴─────────────╯
117+
118+
(4.2) Access Elements
119+
120+
You can access an individual element in a table column by specifying the row index on the selected column:
121+
122+
```mech
123+
a.x[1] -- Select the first element of column `x`, which has kind `f32`
78124
```
79125

80-
5. Kind
126+
Table columns are just vectors, so they support the same indexing operations as vectors.
81127

82-
---
128+
(4.3) Access a Record
83129

84-
A table's kind describes the types and structure of its columns and dimensions. For example:
130+
You can access a record in a table by specifying the row index on the table itself:
85131

86132
```mech
87-
<{u8,string,[u8]:3}:3,3>
133+
a{1} -- Select the first record in the table, which has kind `record`
88134
```
89135

90-
This represents a table with three columns of kinds `u8`, `string`, and `[u8]:3`, and three rows.
136+
5. Heterogeneous Columns
137+
-------------------------------------------------------------------------------
91138

92-
6. Notes
139+
The kind `*` indicates that a column may contain heterogeneous data:
93140

94-
---
141+
```mech:disabled
142+
| x<*> y<*> |
143+
| 1.2 true|
144+
| "Hi" 8 |
145+
```
95146

96-
* Tables are more expressive than matrices and can store structured data.
97-
* They support mixed kinds per column and partial rows.
98-
* Tables are generally slower than matrices due to their flexibility.
147+
Each cell in the column may hold a different type of value.
148+
149+
(5.1) Partial Columns
150+
151+
You can omit values in the table using using `_` to indicate a missing value. In this case, the kind of the column must be annotated with an `option` kind, indicated by a `?` suffix:
152+
153+
```mech:disabled
154+
| x<u8?> y<string?> z<[u8]:1,3?> |
155+
| _ "a" [1 2 3] |
156+
| 4 "b" _ |
157+
| 7 _ [7 8 9] |
158+
```

0 commit comments

Comments
 (0)