]> rethought.computer Git - sorel-lang.git/commitdiff
document var
authorBryan English <bryan@rethought.computer>
Fri, 10 Apr 2026 20:36:42 +0000 (16:36 -0400)
committerBryan English <bryan@rethought.computer>
Fri, 10 Apr 2026 20:36:51 +0000 (16:36 -0400)
docs/language_overview.md

index 19ce351051fd51666c106f682d8692151f4d71a3..b4780f43ed1b5eae6c9fb706532161aa1328537f 100644 (file)
@@ -96,7 +96,9 @@ Exposing Sorel functions to C is also not currently supported, and Sorel _must_
 * `+`, `-`, `*`, `/`, `%` (mod), `|` (bitwise OR) _(TODO add remaining operators)_
   * Arithmetic operators. Pop two values off the stack and operate on them in the order they're added to the stack. Push the result back onto the stack.
 * `sys0`, `sys1`, `sys2`, ..., `sys6`
-  * Make a system call. The number in the word indicates the number of arguments. Call this the same way you'd call an extern.
+  * Make a system call. The number in the word indicates the number of arguments. Call this the same way you'd call an extern. System calls should generally be avoided outside of the stdlib code.
+* `var`
+  * Declares a variable, whose identifier is the subsequent word. Variables are scoped to functions, and must be declared before they are used. They persist _forever_. When the identifier is used as a word after declaration, it puts a pointer to that variable onto the data stack. Variables should be used sparingly, in favour of using the data stack instead.
 
 In order to use `call`, you'll need to get a function pointer.
 These can be retrieved for a given function by prefixing it with an apostrophe `'`.