diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-10-31 22:08:07 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-10-31 22:08:07 -0400 |
| commit | acd2159e1778893ff9d97da1120fb0c6e43a6fc1 (patch) | |
| tree | 8ed956808bd0dc19a8f7e80931d78606e9d6fa0f /docs/spec/evaluate.html | |
| parent | d88e4b093bfaa4df2cb6c75c3ab1cfcd0a108ff3 (diff) | |
Specify that evaluation can fail due to insufficient resources (e.g. memory)
Diffstat (limited to 'docs/spec/evaluate.html')
| -rw-r--r-- | docs/spec/evaluate.html | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/docs/spec/evaluate.html b/docs/spec/evaluate.html index 888ae4f6..82ea88a2 100644 --- a/docs/spec/evaluate.html +++ b/docs/spec/evaluate.html @@ -8,6 +8,7 @@ <p>This page describes the semantics of the code constructs whose grammar is given in <a href="grammar.html">grammar.md</a>. The formation rules there are not named, and here they are identified by either the name of the term or by copying the rule entirely if there are several alternative productions.</p> <p>Here we assume that the referent of each identifier, or equivalently the connections between identifiers, have been identified according to the <a href="scope.html">scoping rules</a>.</p> <p>Evaluation is an ordered process, and any actions required to evaluate a node always have a specified order unless performing them in any order would have the same effect. Side effects that are relevant to ordering are setting and getting the value of a variable, causing an error, and returning (with <code><span class='Gets'>→</span></code>) from a block. Errors described in this page are "evaluation errors" and can be caught by the Catch (<code><span class='Modifier2'>⎊</span></code>) modifier. For caught errors and returns, evaluation halts without attempting to complete any in-progress node, and is restarted by Catch (for errors) or at the end of the appropriate block evaluation (for returns).</p> +<p>As specified, BQN programs can involve an arbitrary amount of information, but when run there will be memory and possibly other limitations. To accommodate this, any part of evaluation can cause an error, if a resource such as memory, stack memory, or limited execution time is exhausted.</p> <h3 id="programs-and-blocks"><a class="header" href="#programs-and-blocks">Programs and blocks</a></h3> <p>The result of parsing a valid BQN program is a <code><span class='Function'>PROGRAM</span></code>, and the program is run by evaluating this term.</p> <p>A <code><span class='Function'>PROGRAM</span></code> or <code><span class='Function'>BODY</span></code> is a list of <code><span class='Function'>STMT</span></code>s, which are evaluated in program order. A result is always required for <code><span class='Function'>BODY</span></code> nodes, and sometimes for <code><span class='Function'>PROGRAM</span></code> nodes (for example, when loaded with <code><span class='Function'>•Import</span></code>). If any identifiers in the node's scope are exported, or any of its statements is an <code><span class='Function'>EXPORT</span></code>, then the result is the namespace created in order to evaluate the node. If a result is required but the namespace case doesn't apply, then the last <code><span class='Function'>STMT</span></code> node must be an <code><span class='Function'>EXPR</span></code> and its result is used. The statement <code><span class='Function'>EXPR</span></code> evaluates some APL code and possibly assigns the results, while <code><span class='Value'>nothing</span></code> evaluates any <code><span class='Value'>subject</span></code> or <code><span class='Function'>Derv</span></code> terms it contains but discards the results. An <code><span class='Function'>EXPORT</span></code> statement performs no action.</p> |
