aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-11-16 21:51:36 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-11-16 21:51:36 -0500
commit5f9908b984825bfcf5acae2c5e804e16ab9622c5 (patch)
tree6ba0702e777a66786640fc5dc9b4a0c9c88ad1d2 /doc
parent0ce5c135c0a97d9e86d14f5b0f2fe80e6b7fc5b1 (diff)
Documentation for modified assignment
Diffstat (limited to 'doc')
-rw-r--r--doc/expression.md7
1 files changed, 7 insertions, 0 deletions
diff --git a/doc/expression.md b/doc/expression.md
index 61985d4b..5f639a0a 100644
--- a/doc/expression.md
+++ b/doc/expression.md
@@ -95,6 +95,13 @@ Assignment can be used inline in an expression, and its result is always the val
2×a←(Neg←-)3
a
+The modification arrow `↩` can also be used to *update* the value of a variable by applying a function. This meaning applies only when there is no expression to the right of `↩` or that expression has a subject role, and there's a function to the left of `↩` (in terms of precedence this function is like an operand—a train must be parenthesized). The two forms of modified assignment are shown below along with equivalent expansions.
+
+| Syntax | Meaning
+|----------|----------
+| `a F↩` | `a ↩ F a`
+| `a F↩ b` | `a ↩ a F b`
+
### Exports
The double arrow `⇐` is used to export variables from a block or program, causing the result to be a [namespace](namespace.md). There are two ways to export variables. First, `←` in the variable definition can be replaced with `⇐` to export the variable as it's defined. Second, an export statement consisting of an assignment target followed by `⇐` with nothing to the right exports the variables in the assignment target and does nothing else. Export statements can be placed anywhere in the relevant program or body, including before declaration or on the last line, and a given variable can be exported any number of times.