diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-12-03 21:43:21 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-12-03 21:43:21 -0500 |
| commit | 916398d2a08c01c684f27b2fce44ff96a6d97e48 (patch) | |
| tree | a0951e033db913d62ec2f850a7acff27a731de49 /spec/scope.md | |
| parent | 2053db2c535ceb5457c30f8ae8832bd37ac3fc2e (diff) | |
Clarifications about special names
Diffstat (limited to 'spec/scope.md')
| -rw-r--r-- | spec/scope.md | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/spec/scope.md b/spec/scope.md index d03ef29d..4c2512e9 100644 --- a/spec/scope.md +++ b/spec/scope.md @@ -10,7 +10,7 @@ A running BQN program manipulates variables during its [execution](evaluate.md), In this section the concept of an identifier's definition, a possibly different instance of that identifier, is specified. The definition determines when identifiers refer to the "same thing". In concrete terms, identifiers with the same definition all manipulate the same variable in a particular instance of the definition's containing scope. -A *scope* is a `PROGRAM`, `blSub`, `CASE`, `I_CASE`, or `A_CASE` node as defined by the BQN [grammar](grammar.md). An *identifier instance* is an `s`, `F`, `_m`, or `_c_` node; its *containing scope* is the "smallest" scope that contains it—the scope that contains the identifier but not any other scopes containing the identifier. An identifier instance is *defined* when it is contained in the left hand side of an `←` assignment expression, that is, the leftmost component of one of the four grammatical rules with `ASGN`, provided that the `ASGN` node is `"←"` or `"⇐"`, or in a scope header, that is, `IMM_HEAD`, `ARG_HEAD`, or the `s` term in `blSub`. Each identifier instance in a valid BQN program corresponds to exactly one such defined identifier, called its *definition*, and two instances are considered to refer to the same identifier if they have the same definition. +A *scope* is a `PROGRAM`, `blSub`, `CASE`, `I_CASE`, or `A_CASE` node as defined by the BQN [grammar](grammar.md). An *identifier instance* is an `s`, `F`, `_m`, or `_c_` node (not including the special names that some block types allow for these terms); its *containing scope* is the "smallest" scope that contains it—the scope that contains the identifier but not any other scopes containing the identifier. An identifier instance is *defined* when it is contained in the left hand side of an `←` assignment expression, that is, the leftmost component of one of the four grammatical rules with `ASGN`, provided that the `ASGN` node is `"←"` or `"⇐"`, or in a scope header, that is, `IMM_HEAD`, `ARG_HEAD`, or the `s` term in `blSub`. Each identifier instance in a valid BQN program corresponds to exactly one such defined identifier, called its *definition*, and two instances are considered to refer to the same identifier if they have the same definition. Two identifier instances have the *same name* if their tokens, as strings, match after removing all underscores `_` and ignoring case (so that the letters a to z are equal to their uppercase equivalents A to Z for this comparison). However, instances with the same name are not necessarily the same identifier, as they must also have the same definition. A defined identifier is a *potential definition* of another identifier instance if the two have the same name, and either: - The defined identifier's containing scope contains the other identifier's containing scope, or @@ -26,7 +26,7 @@ A subject label is the `s` term in a `blSub` node. As part of a header, it can s Special names such as `𝕩` or `𝕣` 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. -The six special names are `𝕨𝕩𝕗𝕘𝕤𝕣`, and the tokens `𝕎𝕏𝔽𝔾𝕊`, `_𝕣`, and `_𝕣_` are alternate spellings of these names as described in the [tokenization rules](token.md). Special names may be modified with `↩` assignment but cannot appear as the target of other kinds of assignment. Two special names represent the same identifier if they are the same name and appear in the same body (more precisely, the set of `BODY` nodes that contains each is the same). The initial value these names have is defined by the [evaluation rules](evaluate.md); the grammar for blocks ensures that all special names used in a block will be defined (possibly as the special value `·` in the case of `𝕨`). +The six special names are `𝕨𝕩𝕗𝕘𝕤𝕣`, and the tokens `𝕎𝕏𝔽𝔾𝕊`, `_𝕣`, and `_𝕣_` are alternate spellings of these names as described in the [tokenization rules](token.md). Special names may be modified with `↩` assignment but cannot appear as the target of other kinds of assignment. Two special names represent the same identifier if they are the same name and appear in the same body (more precisely, the set of `BODY` nodes that contains each is the same). The initial value these names have is defined by the [evaluation rules](evaluate.md); the grammar for blocks ensures that all special names used in a block will be defined (possibly as the special value `·` in the case of `𝕨`). For this reason special names in header rules `headW`, `headX`, `HeadF`, `HeadG`, and `LABEL` are defined to have no effect when evaluated. ### Imports and exports |
