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: SPECIFICATION.html
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -137,6 +137,8 @@
137
137
138
138
Blocks group one or more statements and are enclosed in curly brackets: `{statement1...statementN}`. Curly braces must match (that is, `{` closes with `}`). Blocks serve as the bodies of control-flow constructs and functions.
139
139
140
+
ASYNC blocks: The `ASYNC` statement introduces a background task whose body is a regular block: `ASYNC{ ... }`. The statements inside the block execute synchronously with respect to each other but asynchronously relative to the rest of the program: the interpreter begins executing the block in a background task and immediately continues with the next statement in the current thread. The block shares the main program namespace (it executes with the same lexical environment), so assignments and mutations performed inside an `ASYNC` block are visible to the rest of the program immediately. Runtime errors raised inside an `ASYNC` block are reported via the interpreter's error hooks and recorded in the state log; they do not synchronously abort the main thread. Note that language invariants still apply inside the `ASYNC` block (for example, `RETURN` outside a function is a runtime error).
141
+
140
142
Assignments have the syntax `TYPE : identifier=expression` on first use, where TYPE is `INT`, `STR`, or `TNS`. Spaces around the colon and equals sign are optional. Subsequent assignments to an existing identifier may omit the type but must preserve the original type. Variables are deallocated only when `DEL(identifier)` is executed.
141
143
142
144
Tensor elements can be reassigned with the indexed form `identifier[i1,...,iN]=expression`. The base must be a previously-declared `TNS` binding. The indices must match the tensor's dimensionality, follow the same one-based/negative-index rules as ordinary indexing, and must reference anexisting position. The element's original type cannot change: attempting to store a different type at that position is a runtime error. Indexed assignment mutates the `TNS`.
@@ -166,7 +168,7 @@
166
168
167
169
## 6. Variables and Memory Model
168
170
169
-
A variable is created only when it is first assigned with an explicit type annotation of the form `TYPE : name=expression`, where TYPE is `INT`, `STR`, or `TNS`. For example: `INT` : counter = 0`or`STR` : message="hi"`. Subsequent assignments to the same name must match the declared type and may omit the type annotation (`counter=ADD(counter,1)`). Assigning to an undeclared name without a type annotation is a runtime error. A variable exists until `DEL(name)` is executed. Referencing a variable that has never been declared, or that has been deleted, is a runtime error.
171
+
A variable is created only when it is first assigned with an explicit type annotation of the form `TYPE : name=expression`, where TYPE is `INT`, `STR`, or `TNS`. For example: `INT : counter=0` or `STR : message="hi"`. Subsequent assignments to the same name must match the declared type and may omit the type annotation (`counter=ADD(counter,1)`). Assigning to an undeclared name without a type annotation is a runtime error. A variable exists until `DEL(name)` is executed. Referencing a variable that has never been declared, or that has been deleted, is a runtime error.
170
172
171
173
The language assumes at least a global typed environment mapping identifiers to (type, value) pairs. Function calls create new environments for parameters and local variables, as described in Section 6.2; the precise details of name resolution depend on the chosen scoping rules.
172
174
@@ -343,7 +345,7 @@
343
345
-`EXIT()`or`EXIT(INT:code)`—Requestsimmediateterminationoftheinterpreter.Ifaninteger`code`issupplied,itisusedastheinterpreter's process exit code; otherwise `0` is used. Execution stops immediately when `EXIT` is executed (no further statements run), and an entry is recorded in the state log to make deterministic replay possible. Using `EXIT` inside a function terminates the entire program (not just the function).
-`BYTES(INT: n):TNS`—Convertsanon-negativeintegerintoitsbig-endianbyterepresentation.Theresultisaone-dimensional`TNS`whoseelementsare`INT`valuesintherange`0..11111111`(0-255decimal),orderedmost-significantbytefirst.Thetensorlengthis`max(1, ceil(bit_length(n)/8))`; `BYTES(0)` returns a single zero byte. Supplying a negative integer is a runtime error.
348
+
-`BYTES(INT: n, endian = "big"):TNS`—Convertsanon-negativeintegerintoitsbyterepresentation.Theoptional`endian`parametercontrolsbyteorder: if`endian`is`"little"`theresultislittle-endian(least-significantbytefirst);if`endian`is`"big"`theresultisbig-endian(most-significantbytefirst).Theresultisaone-dimensional`TNS`whoseelementsare`INT`valuesintherange`0..11111111`(0-255decimal).Thetensorlengthis`max(1, ceil(bit_length(n)/8))`;`BYTES(0)`returnsasinglezerobyte.Supplyinganegativeintegerisaruntimeerror.Supplyingan`endian`valueotherthan`"big"`or`"little"`isaruntimeerror.
0 commit comments