From 97ecfc641e5f4a5ee8aef981fdee2d9ec00b24e0 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 30 Jun 2022 13:37:57 -0400 Subject: Can't have aliases in modified assignment either --- docs/spec/evaluate.html | 2 +- spec/evaluate.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/spec/evaluate.html b/docs/spec/evaluate.html index a2568c75..dd267132 100644 --- a/docs/spec/evaluate.html +++ b/docs/spec/evaluate.html @@ -22,7 +22,7 @@

In assignment to lhsList or lhsStr, the right-hand-side value, here called v, must be a list (rank 1 array) or namespace. If it's a list, then each LHS_ENTRY node must be an LHS_ELT. The left-hand side is treated as a list of lhs targets, and matched to v element-wise, with an error if the two lists differ in length. If v is a namespace, then the left-hand side must be an lhsStr where every LHS_ATOM is an NAME, or an lhsList where every LHS_ENTRY is an NAME or lhs "⇐" NAME, so that it can be considered a list of NAME nodes some of which are also associated with lhs nodes. To perform the assignment, the value of each name is obtained from the namespace v, giving an error if v does not define that name. The value is assigned to the lhs node if present (which may be a destructuring assignment or simple subject assignment), and otherwise assigned to the same NAME node used to get it from v.

Assignment to lhsArray destructures the major cells of right-hand-side value v, which must be an array of rank at least 1. The number of cells in v is its length l, that is, the first element of its shape. The shape of each is the shape of v without its first element, and the cell ravels are formed by splitting v's ravel evenly into l sections. Besides this difference in how v is divided, assignment behaves the same way as assignment of a list v to lhsList.

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 encounters an error but it's caught with , some of the assignment may have already been performed, changing variable values.

-

Modified assignment is the subject assignment rule lhs Derv "↩" subExpr?. This case results in an error if lhs contains "·" or an empty lhsArray node (one with no LHS_ELT components). With these conditions, the grammar for lhs is a subset of subExpr; the node is evaluated as if it were a subExpr, and passed as an argument to Derv. The full application is lhs Derv subExpr, if subExpr is given, and Derv lhs otherwise. Its value is assigned to lhs, and is also the result of the modified assignment expression.

+

Modified assignment is the subject assignment rule lhs Derv "↩" subExpr?. This case results in an error if lhs contains "·", "⇐", or an empty lhsArray node (one with no LHS_ELT components). With these conditions, the grammar for lhs is a subset of subExpr; the node is evaluated as if it were a subExpr, and passed as an argument to Derv. The full application is lhs Derv subExpr, if subExpr is given, and Derv lhs otherwise. Its value is assigned to lhs, and is also the result of the modified assignment expression.

Expressions

We now give rules for evaluating an atom, Func, _mod1 or _mod2_ expression (the possible options for ANY). A literal or primitive sl, Fl, _ml, or _cl_ has a fixed value defined by the specification (literals and built-ins). An identifier s, F, _m, or _c_, if not preceded by atom ".", 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 atom ".", then the atom 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 "(" _modExpr ")" 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.

A list "⟨" ? ( ( EXPR )* EXPR ? )? "⟩" or ANY ( "‿" ANY )+ 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 "[" ? ( EXPR )* EXPR ? "]" 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 primitive function Merge (>) to a list of the expression results.

diff --git a/spec/evaluate.md b/spec/evaluate.md index 1a4e4669..97791aba 100644 --- a/spec/evaluate.md +++ b/spec/evaluate.md @@ -36,7 +36,7 @@ Assignment to `lhsArray` destructures the major cells of right-hand-side value ` 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 `↩` encounters an error but it's caught with `⎊`, some of the assignment may have already been performed, changing variable values. -*Modified assignment* is the subject assignment rule `lhs Derv "↩" subExpr?`. This case results in an error if `lhs` contains `"·"` or an empty `lhsArray` node (one with no `LHS_ELT` components). With these conditions, the grammar for `lhs` is a subset of `subExpr`; the node is evaluated as if it were a `subExpr`, and passed as an argument to `Derv`. The full application is `lhs Derv subExpr`, if `subExpr` is given, and `Derv lhs` otherwise. Its value is assigned to `lhs`, and is also the result of the modified assignment expression. +*Modified assignment* is the subject assignment rule `lhs Derv "↩" subExpr?`. This case results in an error if `lhs` contains `"·"`, `"⇐"`, or an empty `lhsArray` node (one with no `LHS_ELT` components). With these conditions, the grammar for `lhs` is a subset of `subExpr`; the node is evaluated as if it were a `subExpr`, and passed as an argument to `Derv`. The full application is `lhs Derv subExpr`, if `subExpr` is given, and `Derv lhs` otherwise. Its value is assigned to `lhs`, and is also the result of the modified assignment expression. ### Expressions -- cgit v1.2.3