diff options
Diffstat (limited to 'docs/tagging.md')
| -rw-r--r-- | docs/tagging.md | 57 |
1 files changed, 52 insertions, 5 deletions
diff --git a/docs/tagging.md b/docs/tagging.md index a469543..b7c0700 100644 --- a/docs/tagging.md +++ b/docs/tagging.md @@ -17,23 +17,23 @@ r : # x / y { If no tag is specified for an operation, `.value` is used -An invalid assertion produces an `Error` +An invalid assertion produces an `Error` with an `.error` tag ```text r : x /.value y r : x / y // same as above ``` -## Coroutines +## Lambdas If no tag is specified `.value` is used, user defined coroutines don't have to have a `.value` tag ### Returning ```text -co : `{[I64 x; I64 y] `return.value x + y } -co : `{[I64 x; I64 y] .value x + y } // same as above -co : `{[I64 x; I64 y] x + y } // same as above +add : `{[I64 x; I64 y] `return.value x + y } +add : `{[I64 x; I64 y] .value x + y } // same as above +add : `{[I64 x; I64 y] x + y } // same as above mu : `{[Bool i] ? i { .int 1 @@ -60,6 +60,38 @@ i : # mu `sync `false { i : mu `sync.int `true ``` +## Generators + +Generators use a `.done` tag to denote when it is complete + +```text +gen : ^{[I64 n] + @ 1 .. n {[x] + `yield x + // above is alias for -> `yield.value x + } + `done +} + +it : gen `init 10 +``` + +### Matching + +```text +v : # `next it { + .value {[x] x } + .done { -1 } +} +``` + +### Asserting + +```text +v : `next.value it +v : `next it // same as above +``` + ## Tables ### Creating @@ -78,4 +110,19 @@ table : Table (.a 1; .b 1.1) ### Break +```text +@.outer condtion { + @ condition { + `break.outer + } +} +``` + ### Continue + +```text +@ (x : 0; x < 10; x +: 2) { + ? x < 5 { `continue } + ... +} +``` |
