aboutsummaryrefslogtreecommitdiff
path: root/spec/evaluate.md
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2022-02-02 09:48:44 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2022-02-02 09:48:44 -0500
commit7c5b02227416911f6ecce3798022837539b41bfb (patch)
tree79d1106c34ccef825b53ddcf6b5559a0d2c754e3 /spec/evaluate.md
parent5d8bfd5f68ceb20e332091cb7133c1b1dbd79b30 (diff)
Grammar
Diffstat (limited to 'spec/evaluate.md')
-rw-r--r--spec/evaluate.md2
1 files changed, 1 insertions, 1 deletions
diff --git a/spec/evaluate.md b/spec/evaluate.md
index 6957ec51..e3b0c212 100644
--- a/spec/evaluate.md
+++ b/spec/evaluate.md
@@ -18,7 +18,7 @@ A `PROGRAM` or `BODY` is a list of `STMT`s, which are evaluated in program order
A block consists of several `BODY` terms, some of which may have an accompanying header describing accepted inputs and how they are processed. An immediate block `brImm` can only have one `BODY`, and is evaluated by evaluating it. Other types of blocks don't evaluate any `BODY` immediately, but instead return a function or modifier that obtains its result by evaluating a particular `BODY`. The `BODY` is identified and evaluated once the block has received enough inputs (operands or arguments), which for modifiers can take one or two calls: if two calls are required, then on the first call the operands are simply stored and no code is evaluated yet. The stored values can be accessed by equality checking, or `•Decompose` if defined. Two calls are required if there is more than one `BODY` term, if the `BODY` contains the special names `𝕨𝕩𝕤𝕎𝕏𝕊`, or if its header specifies arguments (the header-body combination is a `_mCase` or `_cCase_`). Otherwise only one is required.
-To evaluate a block when enough inputs have been received, first the correct case must be identified. To do this, first each special case (`I_CASE` or `A_CASE`), excluding `A_CASE` nodes whose `ARG_HEAD` contains `"⁼"`, is checked in order to see if its arguments are strucurally compatible with the given arguments. That is, is `headW` is an `lhs`, there must be a left argument matching that structure, and if `headX` is an `lhs`, the right argument must match that structure. This means that `𝕨` not only matches any left argument but also no argument. The test for compatibility is the same as for multiple assignment described below, except that the header may contain constants, which must match the corresponding part of the given argument. If no special case matches, then an appropriate general `CASE` is used: if there are two, the first is used with no left argument and the second with a left argument; if there are one, it is always used, and if there are none, an error results.
+To evaluate a block when enough inputs have been received, first the correct case must be identified. To do this, first each special case (`I_CASE` or `A_CASE`), excluding `A_CASE` nodes whose `ARG_HEAD` contains `"⁼"`, is checked in order to see if its arguments are strucurally compatible with the given arguments. That is, is `headW` is an `lhs`, there must be a left argument matching that structure, and if `headX` is an `lhs`, the right argument must match that structure. This means that `𝕨` not only matches any left argument but also no argument. The test for compatibility is the same as for multiple assignment described below, except that the header may contain constants, which must match the corresponding part of the given argument. If no special case matches, then an appropriate general `CASE` is used: if there are two, the first is used with no left argument and the second with a left argument; if there is one, it is always used, and if there are none, an error results.
When a predicate `"?"` is evaluated, it may change the choice of case. The associated `EXPR` is evaluated and its result is checked. If it's not one of the numbers `0` or `1`, an error results. If it's `1`, evaluation of the `BODY` continues as usual. If it's `0`, evaluation is stopped and the next compatible `BODY` term is evaluated using the block's original inputs.