diff options
Diffstat (limited to 'docs/spec/scope.html')
| -rw-r--r-- | docs/spec/scope.html | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/docs/spec/scope.html b/docs/spec/scope.html index ef92f370..3cc01659 100644 --- a/docs/spec/scope.html +++ b/docs/spec/scope.html @@ -17,7 +17,7 @@ <li>The two identifiers are the same instance (a defined variable is its own definition).</li> </ul> <p>The definition for an identifier is chosen from the potential definitions based on their containing scopes: it is the one whose containing scope does not contain or match the containing scope of any other potential definition. If for any identifier there is no definition, then the program is not valid and results in an error. This can occur if the identifier has no potential definition, and also if two potential definitions appear in the same scope. In fact, under this scheme it is never valid to make two definitions with the same name at the top level of a single scope, because both definitions would be potential definitions for the one that comes second in program order. Both definitions have the same containing scope, and any potential definition must contain or match this scope, so no potential definition can be selected.</p> -<p>The definition of <em>program order</em> for identifier tokens follows the order of BQN <a href="evaluate.html">execution</a>. It corresponds to the order of a particular traversal of the abstract syntax tree for a program. To find the relative ordering of two identifiers in a program, we consider the highest-depth node that they both belong to; in this node they must occur in different components, or that component would be a higher-depth node containing both of them. In most nodes, the program order goes from right to left: components further to the right come earlier in program order. The exceptions are <code><span class='Function'>PROGRAM</span></code>, <code><span class='Function'>BODY</span></code>, <code><span class='Value'>list</span></code>, <code><span class='Value'>subject</span></code> (for stranding), <code><span class='Value'>lhsList</span></code>, <code><span class='Value'>lhsStr</span></code>, and body structure (<code><span class='Function'>I_CASE</span></code>, <code><span class='Function'>A_CASE</span></code>, <code><span class='Function'>IMM_BLK</span></code>, <code><span class='Function'>ARG_BLK</span></code>, and <code><span class='Value'>blSub</span></code>) nodes, in which program order goes in the opposite order, from left to right.</p> +<p>The definition of <em>program order</em> for identifier tokens follows the order of BQN <a href="evaluate.html">execution</a>. It corresponds to the order of a particular traversal of the abstract syntax tree for a program. To find the relative ordering of two identifiers in a program, we consider the highest-depth node that they both belong to; in this node they must occur in different components, or that component would be a higher-depth node containing both of them. In most nodes, the program order goes from right to left: components further to the right come earlier in program order. The exceptions are <code><span class='Function'>PROGRAM</span></code>, <code><span class='Function'>BODY</span></code>, <code><span class='Value'>array</span></code>, <code><span class='Value'>subject</span></code> (for stranding), <code><span class='Value'>lhsList</span></code>, <code><span class='Value'>lhsArray</span></code>, <code><span class='Value'>lhsStr</span></code>, and body structure (<code><span class='Function'>I_CASE</span></code>, <code><span class='Function'>A_CASE</span></code>, <code><span class='Function'>IMM_BLK</span></code>, <code><span class='Function'>ARG_BLK</span></code>, and <code><span class='Value'>blSub</span></code>) nodes, in which program order goes in the opposite order, from left to right.</p> <p>A subject label is the <code><span class='Value'>s</span></code> term in a <code><span class='Value'>blSub</span></code> node. As part of a header, it can serve as the definition for an identifier. However, it's defined to be a syntax error if another instance of this identifier appears.</p> <h3 id="special-names"><a class="header" href="#special-names">Special names</a></h3> <p>Special names such as <code><span class='Value'>𝕩</span></code> or <code><span class='Value'>𝕣</span></code> refer to variables, but have no definition and do not use scoping. Instead, they always refer to the immediately enclosing scope, and are defined automatically when the block is evaluated.</p> |
