aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2022-06-30 10:27:47 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2022-06-30 10:27:47 -0400
commit4e254ba07aba2ee0f21cd7ec2811e279beb6a7a2 (patch)
treef3b923fd84d83c727b6d926f0a5152f037c65162 /docs
parent1c598b836ad34d87b4799bb933fe76ba0a4132f4 (diff)
Fix modified assignment spec to account for · and []
Diffstat (limited to 'docs')
-rw-r--r--docs/spec/evaluate.html2
1 files changed, 1 insertions, 1 deletions
diff --git a/docs/spec/evaluate.html b/docs/spec/evaluate.html
index 8c99de10..a2568c75 100644
--- a/docs/spec/evaluate.html
+++ b/docs/spec/evaluate.html
@@ -22,7 +22,7 @@
<p>In assignment to <code><span class='Value'>lhsList</span></code> or <code><span class='Value'>lhsStr</span></code>, the right-hand-side value, here called <code><span class='Value'>v</span></code>, must be a list (rank 1 array) or namespace. If it's a list, then each <code><span class='Function'>LHS_ENTRY</span></code> node must be an <code><span class='Function'>LHS_ELT</span></code>. The left-hand side is treated as a list of <code><span class='Value'>lhs</span></code> targets, and matched to <code><span class='Value'>v</span></code> element-wise, with an error if the two lists differ in length. If <code><span class='Value'>v</span></code> is a namespace, then the left-hand side must be an <code><span class='Value'>lhsStr</span></code> where every <code><span class='Function'>LHS_ATOM</span></code> is an <code><span class='Function'>NAME</span></code>, or an <code><span class='Value'>lhsList</span></code> where every <code><span class='Function'>LHS_ENTRY</span></code> is an <code><span class='Function'>NAME</span></code> or <code><span class='Value'>lhs</span> <span class='String'>&quot;⇐&quot;</span> <span class='Function'>NAME</span></code>, so that it can be considered a list of <code><span class='Function'>NAME</span></code> nodes some of which are also associated with <code><span class='Value'>lhs</span></code> nodes. To perform the assignment, the value of each name is obtained from the namespace <code><span class='Value'>v</span></code>, giving an error if <code><span class='Value'>v</span></code> does not define that name. The value is assigned to the <code><span class='Value'>lhs</span></code> node if present (which may be a destructuring assignment or simple subject assignment), and otherwise assigned to the same <code><span class='Function'>NAME</span></code> node used to get it from <code><span class='Value'>v</span></code>.</p>
<p>Assignment to <code><span class='Value'>lhsArray</span></code> destructures the major cells of right-hand-side value <code><span class='Value'>v</span></code>, which must be an array of rank at least 1. The number of cells in <code><span class='Value'>v</span></code> is its length <code><span class='Value'>l</span></code>, that is, the first element of its shape. The shape of each is the shape of <code><span class='Value'>v</span></code> without its first element, and the cell ravels are formed by splitting <code><span class='Value'>v</span></code>'s ravel evenly into <code><span class='Value'>l</span></code> sections. Besides this difference in how <code><span class='Value'>v</span></code> is divided, assignment behaves the same way as assignment of a list <code><span class='Value'>v</span></code> to <code><span class='Value'>lhsList</span></code>.</p>
<p>A destructuring assignment is performed in program order, or equivalently index order, with each sub-assignment fully completed before beginning the next (a depth-first order). Thus if an assignment with <code><span class='Gets'>↩</span></code> encounters an error but it's caught with <code><span class='Modifier2'>⎊</span></code>, some of the assignment may have already been performed, changing variable values.</p>
-<p><em>Modified assignment</em> is the subject assignment rule <code><span class='Value'>lhs</span> <span class='Function'>Derv</span> <span class='String'>&quot;↩&quot;</span> <span class='Value'>subExpr</span><span class='Head'>?</span></code>. In this case, <code><span class='Value'>lhs</span></code> is evaluated as if it were a <code><span class='Value'>subExpr</span></code> (the syntax is a subset of <code><span class='Value'>subExpr</span></code>), and passed as an argument to <code><span class='Function'>Derv</span></code>. The full application is <code><span class='Value'>lhs</span> <span class='Function'>Derv</span> <span class='Value'>subExpr</span></code>, if <code><span class='Value'>subExpr</span></code> is given, and <code><span class='Function'>Derv</span> <span class='Value'>lhs</span></code> otherwise. Its value is assigned to <code><span class='Value'>lhs</span></code>, and is also the result of the modified assignment expression.</p>
+<p><em>Modified assignment</em> is the subject assignment rule <code><span class='Value'>lhs</span> <span class='Function'>Derv</span> <span class='String'>&quot;↩&quot;</span> <span class='Value'>subExpr</span><span class='Head'>?</span></code>. This case results in an error if <code><span class='Value'>lhs</span></code> contains <code><span class='String'>&quot;·&quot;</span></code> or an empty <code><span class='Value'>lhsArray</span></code> node (one with no <code><span class='Function'>LHS_ELT</span></code> components). With these conditions, the grammar for <code><span class='Value'>lhs</span></code> is a subset of <code><span class='Value'>subExpr</span></code>; the node is evaluated as if it were a <code><span class='Value'>subExpr</span></code>, and passed as an argument to <code><span class='Function'>Derv</span></code>. The full application is <code><span class='Value'>lhs</span> <span class='Function'>Derv</span> <span class='Value'>subExpr</span></code>, if <code><span class='Value'>subExpr</span></code> is given, and <code><span class='Function'>Derv</span> <span class='Value'>lhs</span></code> otherwise. Its value is assigned to <code><span class='Value'>lhs</span></code>, and is also the result of the modified assignment expression.</p>
<h3 id="expressions"><a class="header" href="#expressions">Expressions</a></h3>
<p>We now give rules for evaluating an <code><span class='Value'>atom</span></code>, <code><span class='Function'>Func</span></code>, <code><span class='Modifier'>_mod1</span></code> or <code><span class='Modifier2'>_mod2_</span></code> expression (the possible options for <code><span class='Function'>ANY</span></code>). A literal or primitive <code><span class='Value'>sl</span></code>, <code><span class='Function'>Fl</span></code>, <code><span class='Modifier'>_ml</span></code>, or <code><span class='Modifier2'>_cl_</span></code> has a fixed value defined by the specification (<a href="literal.html">literals</a> and <a href="primitive.html">built-ins</a>). An identifier <code><span class='Value'>s</span></code>, <code><span class='Function'>F</span></code>, <code><span class='Modifier'>_m</span></code>, or <code><span class='Modifier2'>_c_</span></code>, if not preceded by <code><span class='Value'>atom</span> <span class='String'>&quot;.&quot;</span></code>, must have an associated variable due to the scoping rules, and returns this variable's value, or causes an error if it has not yet been set. If it is preceded by <code><span class='Value'>atom</span> <span class='String'>&quot;.&quot;</span></code>, then the <code><span class='Value'>atom</span></code> node is evaluated first; its value must be a namespace, and the result is the value of the identifier's name in the namespace, or an error if the name is undefined. A parenthesized expression such as <code><span class='String'>&quot;(&quot;</span> <span class='Modifier'>_modExpr</span> <span class='String'>&quot;)&quot;</span></code> simply returns the result of the interior expression. A block is defined by the evaluation of the statements it contains after all parameters are accepted, as described above.</p>
<p>A list <code><span class='String'>&quot;⟨&quot;</span> <span class='Separator'>⋄</span><span class='Head'>?</span> <span class='Paren'>(</span> <span class='Paren'>(</span> <span class='Function'>EXPR</span> <span class='Separator'>⋄</span> <span class='Paren'>)</span><span class='Value'>*</span> <span class='Function'>EXPR</span> <span class='Separator'>⋄</span><span class='Head'>?</span> <span class='Paren'>)</span><span class='Head'>?</span> <span class='String'>&quot;⟩&quot;</span></code> or <code><span class='Function'>ANY</span> <span class='Paren'>(</span> <span class='String'>&quot;‿&quot;</span> <span class='Function'>ANY</span> <span class='Paren'>)</span><span class='Function'>+</span></code> consists grammatically of a list of expressions. To evaluate it, each expression is evaluated in source order and their results are placed as elements of a rank-1 array. The two forms have identical semantics but different punctuation. The square bracket notation <code><span class='String'>&quot;[&quot;</span> <span class='Separator'>⋄</span><span class='Head'>?</span> <span class='Paren'>(</span> <span class='Function'>EXPR</span> <span class='Separator'>⋄</span> <span class='Paren'>)</span><span class='Value'>*</span> <span class='Function'>EXPR</span> <span class='Separator'>⋄</span><span class='Head'>?</span> <span class='String'>&quot;]&quot;</span></code> evaluates expressions in the same way, but makes them into major cells of an array instead of elements. The result is identical to applying the <a href="primitive.html">primitive</a> function Merge (<code><span class='Function'>&gt;</span></code>) to a list of the expression results.</p>