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
-**Named arguments:**`foo([name = value])` with square brackets — NOT `foo(name=value)`
56
56
-**Block arguments with `<|`:** use `$()` or `@()` prefix: `defer() <| $() { ... }` — NOT `defer <| { ... }` (bare `{ }` creates a table literal)
57
57
-**Lambda:**`@(args) { body }` or `@@(args) { body }` (no-capture)
58
+
-**Generator:**`$() { yield value; }` or `$ { yield value; }` — both are valid gen2 syntax
59
+
-**Tuple `=>` operator:**`a => b` creates a `tuple<auto;auto>` — useful in LINQ, table construction, and ad-hoc pairs
58
60
-**Bitfield variables** need explicit type for `.field` access and printing: `var f : MyBitfield`
59
61
-**Bitfield dot access:** read with `f.flag` (returns bool), write with `f.flag = true/false`
60
62
-**`typeinfo`** special syntax: `typeinfo enum_length(type<MyEnum>)` — NOT `typeinfo(enum_length type<MyEnum>)`
@@ -110,6 +112,10 @@ All code examples and documentation MUST use gen2 syntax (add `options gen2` at
110
112
- When calling `apply_template`, always capture the return value: `unsafe { expr <- apply_template(expr) <| ... }` — discarding the return loses the expression data
111
113
- Iterator comprehension: `[iterator for(x in src); expression]` — semicolon separates generator from body
112
114
-`to_array` (from `daslib/builtin`) converts any iterator to an array
115
+
- Lambdas CAN be stored in arrays: `var fns : array<lambda<(x:int):int>>` + `fns |> emplace() <| @(x : int) : int { return x * 2; }` — move semantics, not copy
116
+
- Blocks CANNOT be stored in containers, returned from functions, or captured — use lambdas or function pointers for those use cases
117
+
-`match`, `multi_match`, `static_match` macros (from `daslib/match.das`) handle side effects automatically — do NOT add `[sideeffects]` annotations to functions that only use match
118
+
-`[export] def main()` returns `void` — do NOT `return true` or return other values from main
113
119
114
120
## Key Directories
115
121
@@ -175,6 +181,45 @@ When editing RST files in `doc/source/reference/language/`:
RST uses two table formats — **grid tables** and **simple tables**. Both are fragile:
187
+
188
+
-**Grid tables** (`+---+---+`): Every row line must be exactly the same width as every separator line. Off-by-one spaces cause Sphinx errors.
189
+
-**Simple tables** (`=== ===`): The `=` separator defines column widths. Content in non-last columns must NOT extend past its column's `=` boundary. Headers must start at or after the column's start position (not in the gap). The gap between columns must be at least 2 spaces.
190
+
- After creating or editing any RST table, verify the file with a Sphinx build (see below).
191
+
192
+
### Documentation workflow (REQUIRED)
193
+
194
+
After creating or modifying any RST files, stdlib documentation, or `daslib/*.das` module doc-comments:
195
+
196
+
1.**Regenerate stdlib docs** (if `daslib/*.das` files or `doc/reflections/das2rst.das` were changed):
Remove-Item -Recurse -Force ../site/doc # delete HTML output
206
+
sphinx-build -b html -d sphinx-build source ../site/doc
207
+
```
208
+
On Linux/Mac:
209
+
```
210
+
cd doc
211
+
rm -rf sphinx-build ../site/doc
212
+
sphinx-build -b html -d sphinx-build source ../site/doc
213
+
```
214
+
215
+
3.**Verify no new errors or warnings**: Check the build output for `ERROR` and `WARNING`. The build must introduce **no new** Sphinx errors or warnings compared to the baseline.
216
+
217
+
**When to run the workflow:**
218
+
- New or modified RST files (language docs, tutorials, stdlib docs)
219
+
- New or modified `//!` doc-comments in `daslib/*.das` files
220
+
- Changes to `doc/reflections/das2rst.das` or `doc/reflections/rst.das`
221
+
- New public functions added to any `daslib/*.das` module (also update `group_by_regex` in `das2rst.das`)
222
+
178
223
### Tutorial RST conventions
179
224
180
225
Tutorial RST files live in `doc/source/reference/tutorials/` with companion `.das` files in `tutorials/language/`.
-**Named arguments:**`foo([name = value])` with square brackets — NOT `foo(name=value)`
56
56
-**Block arguments with `<|`:** use `$()` or `@()` prefix: `defer() <| $() { ... }` — NOT `defer <| { ... }` (bare `{ }` creates a table literal)
57
57
-**Lambda:**`@(args) { body }` or `@@(args) { body }` (no-capture)
58
+
-**Generator:**`$() { yield value; }` or `$ { yield value; }` — both are valid gen2 syntax
59
+
-**Tuple `=>` operator:**`a => b` creates a `tuple<auto;auto>` — useful in LINQ, table construction, and ad-hoc pairs
58
60
-**Bitfield variables** need explicit type for `.field` access and printing: `var f : MyBitfield`
59
61
-**Bitfield dot access:** read with `f.flag` (returns bool), write with `f.flag = true/false`
60
62
-**`typeinfo`** special syntax: `typeinfo enum_length(type<MyEnum>)` — NOT `typeinfo(enum_length type<MyEnum>)`
@@ -110,6 +112,10 @@ All code examples and documentation MUST use gen2 syntax (add `options gen2` at
110
112
- When calling `apply_template`, always capture the return value: `unsafe { expr <- apply_template(expr) <| ... }` — discarding the return loses the expression data
111
113
- Iterator comprehension: `[iterator for(x in src); expression]` — semicolon separates generator from body
112
114
-`to_array` (from `daslib/builtin`) converts any iterator to an array
115
+
- Lambdas CAN be stored in arrays: `var fns : array<lambda<(x:int):int>>` + `fns |> emplace() <| @(x : int) : int { return x * 2; }` — move semantics, not copy
116
+
- Blocks CANNOT be stored in containers, returned from functions, or captured — use lambdas or function pointers for those use cases
117
+
-`match`, `multi_match`, `static_match` macros (from `daslib/match.das`) handle side effects automatically — do NOT add `[sideeffects]` annotations to functions that only use match
118
+
-`[export] def main()` returns `void` — do NOT `return true` or return other values from main
113
119
114
120
## Key Directories
115
121
@@ -175,6 +181,45 @@ When editing RST files in `doc/source/reference/language/`:
RST uses two table formats — **grid tables** and **simple tables**. Both are fragile:
187
+
188
+
-**Grid tables** (`+---+---+`): Every row line must be exactly the same width as every separator line. Off-by-one spaces cause Sphinx errors.
189
+
-**Simple tables** (`=== ===`): The `=` separator defines column widths. Content in non-last columns must NOT extend past its column's `=` boundary. Headers must start at or after the column's start position (not in the gap). The gap between columns must be at least 2 spaces.
190
+
- After creating or editing any RST table, verify the file with a Sphinx build (see below).
191
+
192
+
### Documentation workflow (REQUIRED)
193
+
194
+
After creating or modifying any RST files, stdlib documentation, or `daslib/*.das` module doc-comments:
195
+
196
+
1.**Regenerate stdlib docs** (if `daslib/*.das` files or `doc/reflections/das2rst.das` were changed):
Remove-Item -Recurse -Force ../site/doc # delete HTML output
206
+
sphinx-build -b html -d sphinx-build source ../site/doc
207
+
```
208
+
On Linux/Mac:
209
+
```
210
+
cd doc
211
+
rm -rf sphinx-build ../site/doc
212
+
sphinx-build -b html -d sphinx-build source ../site/doc
213
+
```
214
+
215
+
3.**Verify no new errors or warnings**: Check the build output for `ERROR` and `WARNING`. The build must introduce **no new** Sphinx errors or warnings compared to the baseline.
216
+
217
+
**When to run the workflow:**
218
+
- New or modified RST files (language docs, tutorials, stdlib docs)
219
+
- New or modified `//!` doc-comments in `daslib/*.das` files
220
+
- Changes to `doc/reflections/das2rst.das` or `doc/reflections/rst.das`
221
+
- New public functions added to any `daslib/*.das` module (also update `group_by_regex` in `das2rst.das`)
222
+
178
223
### Tutorial RST conventions
179
224
180
225
Tutorial RST files live in `doc/source/reference/tutorials/` with companion `.das` files in `tutorials/language/`.
@@ -280,6 +282,7 @@ class DecsQueryMacro : AstCallMacro {
280
282
//!
281
283
//! query(kaboom) <| $ ( var pos:float3&; vel:float3; col:uint=13u )
282
284
//! pos += vel
285
+
//!
283
286
//! The query above will add the velocity to the position of an entity with eid kaboom.
284
287
//!
285
288
//! Query can have `REQUIRE` and `REQUIRE_NOT` clauses::
@@ -302,7 +305,7 @@ class DecsQueryMacro : AstCallMacro {
302
305
//!
303
306
//! In the example above structure q : Particle does not exist as a variable. Instead it is expanded into accessing individual components of the entity.
304
307
//! REQURE section of the query is automatically filled with all components of the template.
305
-
//! If template prefix is not specified, prefix is taken from the name of the template (would be "Particle_").
308
+
//! If template prefix is not specified, prefix is taken from the name of the template (would be ``Particle_``).
306
309
//! Specifying empty prefix `[decs_template(prefix)]` will result in no prefix being added.
307
310
//!
308
311
//! Note: apart from tagging structure as a template, the macro also generates `apply_decs_template` and `remove_decs_template` functions.
@@ -477,10 +480,12 @@ class DecsQueryMacro : AstCallMacro {
477
480
478
481
[call_macro(name="find_query")]
479
482
classDecsFindQueryMacro : DecsQueryMacro {
480
-
//! This macro implements 'find_query` functionality.
483
+
//! This macro implements `find_query` functionality.
481
484
//! It is similar to `query` in most ways, with the main differences being:
482
-
//! * there is no eid-based find query
483
-
//! * the find_query stops once the first match is found
485
+
//!
486
+
//! * there is no eid-based find query
487
+
//! * the find_query stops once the first match is found
488
+
//!
484
489
//! For example::
485
490
//!
486
491
//! let found = find_query <| $ ( pos,dim:float3; obstacle:Obstacle )
@@ -500,7 +505,7 @@ class DecsFindQueryMacro : DecsQueryMacro {
500
505
501
506
[function_macro(name="decs")]
502
507
classDecsEcsMacro : AstFunctionAnnotation {
503
-
//! This macro converts a function into a DECS pass stage query. Possible arguments are `stage`, 'REQUIRE', and `REQUIRE_NOT`.
508
+
//! This macro converts a function into a DECS pass stage query. Possible arguments are `stage`, `REQUIRE`, and `REQUIRE_NOT`.
504
509
//! It has all other properties of a `query` (like ability to operate on templates). For example::
505
510
//!
506
511
//! [decs(stage=update_ai, REQUIRE=ai_turret)]
@@ -587,12 +592,15 @@ class DecsEcsMacro : AstFunctionAnnotation {
587
592
[call_macro(name="from_decs")]
588
593
classFromDecsMacro : AstCallMacro {
589
594
//! This macro converts a DECS query into an iterator<tuple<...>>. For example::
595
+
//!
590
596
//! let it = from_decs($(index:int; text:string){})
0 commit comments