aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-11-29 20:55:22 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-11-29 20:55:22 -0500
commitfb3580660898306105c2e1f041f29bbdb9006210 (patch)
treeb704efe38eb38c0ebfdc3c7cbb8a37eba52be953
parenta7148422c8f4a69134263b4d37d05499996aaa7c (diff)
Remove return (→) from the spec
-rw-r--r--docs/spec/evaluate.html3
-rw-r--r--docs/spec/grammar.html4
-rw-r--r--docs/spec/scope.html2
-rw-r--r--docs/spec/token.html2
-rw-r--r--spec/evaluate.md4
-rw-r--r--spec/grammar.md4
-rw-r--r--spec/scope.md4
-rw-r--r--spec/token.md2
8 files changed, 6 insertions, 19 deletions
diff --git a/docs/spec/evaluate.html b/docs/spec/evaluate.html
index 9b57dd5f..44a337b5 100644
--- a/docs/spec/evaluate.html
+++ b/docs/spec/evaluate.html
@@ -7,7 +7,7 @@
<h1 id="specification-bqn-evaluation"><a class="header" href="#specification-bqn-evaluation">Specification: BQN evaluation</a></h1>
<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 &quot;evaluation errors&quot; 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>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, and causing an error. Errors described in this page are &quot;evaluation errors&quot; and can be caught by the Catch (<code><span class='Modifier2'>⎊</span></code>) modifier. If caught, evaluation halts without attempting to complete any in-progress node, and is restarted by Catch.</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>
@@ -23,7 +23,6 @@
<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></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>
<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 braced construct such as <code><span class='Function'>BraceFunc</span></code> is defined by the evaluation of the statements it contains after all parameters are accepted. Finally, a list <code><span class='String'>&quot;⟨&quot;</span> <span class='Separator'>⋄</span><span class='Value'>?</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='Value'>?</span> <span class='Paren'>)</span><span class='Value'>?</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.</p>
-<p>A <code><span class='Function'>Return</span></code> node creates a return function. As <a href="scope.html#returns">discussed</a> in the scoping rules, its identifier indicates a namespace from a particular block evaluation. When called, the function causes an error if that block has finished execution, or if the call includes a left argument <code><span class='Value'>𝕨</span></code>. Otherwise, evaluation stops immediately, and resumes at the end of the block where it returns the right argument <code><span class='Value'>𝕩</span></code> from that block.</p>
<p>Rules in the table below are function and modifier evaluation.</p>
<table>
<thead>
diff --git a/docs/spec/grammar.html b/docs/spec/grammar.html
index 99058319..d28fa55b 100644
--- a/docs/spec/grammar.html
+++ b/docs/spec/grammar.html
@@ -32,12 +32,10 @@
</span> <span class='Function'>|</span> <span class='Function'>Operand</span> <span class='Modifier2'>_mod2_</span> <span class='Comment'># Left partial application
</span> <span class='Function'>|</span> <span class='Modifier'>_m</span> <span class='Function'>ASGN</span> <span class='Modifier'>_m1Expr</span>
</pre>
-<p>Functions can be formed by fully applying modifiers, as trains, or with the return token <code><span class='Gets'>→</span></code>, which behaves syntactically like a 1-modifier whose operand must be an identifier. Modifiers are left-associative, so that the left operand (<code><span class='Function'>Operand</span></code>) can include modifier applications but the right operand (<code><span class='Value'>subject</span> <span class='Function'>|</span> <span class='Function'>Func</span></code>) cannot. Trains are right-associative, but bind less tightly than modifiers. Assignment is not allowed in the top level of a train: it must be parenthesized.</p>
+<p>Functions can be formed by fully applying modifiers or as trains. Modifiers are left-associative, so that the left operand (<code><span class='Function'>Operand</span></code>) can include modifier applications but the right operand (<code><span class='Value'>subject</span> <span class='Function'>|</span> <span class='Function'>Func</span></code>) cannot. Trains are right-associative, but bind less tightly than modifiers. Assignment is not allowed in the top level of a train: it must be parenthesized.</p>
<pre><span class='Function'>Derv</span> <span class='Function'>=</span> <span class='Function'>Func</span>
<span class='Function'>|</span> <span class='Function'>Operand</span> <span class='Modifier'>_mod1</span>
<span class='Function'>|</span> <span class='Function'>Operand</span> <span class='Modifier2'>_mod2_</span> <span class='Paren'>(</span> <span class='Value'>subject</span> <span class='Function'>|</span> <span class='Function'>Func</span> <span class='Paren'>)</span>
- <span class='Function'>|</span> <span class='Function'>Return</span>
-<span class='Function'>Return</span> <span class='Function'>=</span> <span class='Paren'>(</span> <span class='Function'>NAME</span> <span class='Function'>|</span> <span class='String'>&quot;𝕊&quot;</span> <span class='Function'>|</span> <span class='String'>&quot;𝕣&quot;</span> <span class='Paren'>)</span> <span class='String'>&quot;→&quot;</span>
<span class='Function'>Operand</span> <span class='Function'>=</span> <span class='Value'>subject</span>
<span class='Function'>|</span> <span class='Function'>Derv</span>
<span class='Function'>Fork</span> <span class='Function'>=</span> <span class='Function'>Derv</span>
diff --git a/docs/spec/scope.html b/docs/spec/scope.html
index 5576f6c8..a4663def 100644
--- a/docs/spec/scope.html
+++ b/docs/spec/scope.html
@@ -30,5 +30,3 @@
<p>When a body in a block is evaluated, it creates a <em>namespace</em>, which contains a variable for each definition (that is, defined identifier instance) the body contains. Whenever another block—the block itself, not its contents—is evaluated during the execution of the block, it is linked to the currently-evaluating block, so that it will use the variables defined in this instance. By following these links repeatedly, an instance of a block is always linked to exactly one instance of each block that contains it. These links form a tree that is not necessarily related to the call stack of functions and modifiers. Using the links, the variable an identifier refers to is the one corresponding to that variable's definition in the linked instance of the containing scope for the definition.</p>
<p>The first access to a variable must be made by its definition (this also means it sets the variable). If a different instance of its identifier accesses it first, then an error results. This can happen because every scope contained in a particular scope sees all the definitions it uses, and such a scope could be called before the definition is run. Because of conditional execution, this property must be checked at run time in general; however, in cases where it is possible to statically determine that a program will always violate it, a BQN instance can give an error at compile time rather than run time.</p>
<p>A namespace defines a mapping from names to variables: if the given name is shared by an exported identifier in the body used to create that namespace, then that name maps to the variable corresponding to that identifier. The mapping is undefined for other names.</p>
-<h2 id="returns"><a class="header" href="#returns">Returns</a></h2>
-<p>The name <code><span class='Function'>NAME</span> <span class='Function'>|</span> <span class='String'>&quot;𝕊&quot;</span> <span class='Function'>|</span> <span class='String'>&quot;𝕣&quot;</span></code> in a <code><span class='Function'>Return</span></code> node is resolved exactly like any other identifier. Following resolution, the block that defines the identifier must not be a namespace block (export variables or contain an <code><span class='Function'>EXPORT</span></code> statement). Furthermore, if it is a <code><span class='Function'>NAME</span></code>, then its definition must be an internal name for a containing block: <code><span class='Value'>s</span></code> in <code><span class='Value'>brSub</span></code>, <code><span class='Function'>F</span></code> in <code><span class='Function'>FuncHead</span></code> or <code><span class='Function'>FMain</span></code>, <code><span class='Modifier'>_m</span></code> in <code><span class='Function'>Mod1H1</span></code> or <code><span class='Modifier'>_mMain</span></code>, or <code><span class='Modifier2'>_c_</span></code> in <code><span class='Function'>Mod2H1</span></code> or <code><span class='Modifier2'>_cMain_</span></code>. When reached, the <code><span class='Function'>Return</span></code> node's identifier is not accessed; instead, it is used to indicate the namespace that contains it, and through this the block evaluation that created that namespace.</p>
diff --git a/docs/spec/token.html b/docs/spec/token.html
index acf8dc4b..b935b9b9 100644
--- a/docs/spec/token.html
+++ b/docs/spec/token.html
@@ -43,7 +43,7 @@
</tr>
<tr>
<td>Punctuation</td>
-<td><code><span class='Gets'>←⇐↩→</span><span class='Paren'>()</span><span class='Brace'>{}</span><span class='Bracket'>⟨⟩</span><span class='Ligature'>‿</span><span class='Separator'>⋄,</span><span class='Value'>.</span></code> and newline</td>
+<td><code><span class='Gets'>←⇐↩</span><span class='Paren'>()</span><span class='Brace'>{}</span><span class='Bracket'>⟨⟩</span><span class='Ligature'>‿</span><span class='Separator'>⋄,</span><span class='Value'>.</span></code> and newline</td>
</tr>
</tbody>
</table>
diff --git a/spec/evaluate.md b/spec/evaluate.md
index 7274722a..7bcbf5a6 100644
--- a/spec/evaluate.md
+++ b/spec/evaluate.md
@@ -6,7 +6,7 @@ This page describes the semantics of the code constructs whose grammar is given
Here we assume that the referent of each identifier, or equivalently the connections between identifiers, have been identified according to the [scoping rules](scope.md).
-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 `→`) from a block. Errors described in this page are "evaluation errors" and can be caught by the Catch (`⎊`) 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).
+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, and causing an error. Errors described in this page are "evaluation errors" and can be caught by the Catch (`⎊`) modifier. If caught, evaluation halts without attempting to complete any in-progress node, and is restarted by Catch.
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.
@@ -38,8 +38,6 @@ The right-hand-side value, here called `v`, in destructuring assignment must be
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](literal.md) and [built-ins](primitive.md)). 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 braced construct such as `BraceFunc` is defined by the evaluation of the statements it contains after all parameters are accepted. Finally, 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.
-A `Return` node creates a return function. As [discussed](scope.md#returns) in the scoping rules, its identifier indicates a namespace from a particular block evaluation. When called, the function causes an error if that block has finished execution, or if the call includes a left argument `𝕨`. Otherwise, evaluation stops immediately, and resumes at the end of the block where it returns the right argument `𝕩` from that block.
-
Rules in the table below are function and modifier evaluation.
| L | Left | Called | Right | R | Types
|-----|---------------------------|----------|-----------------------|-----|-----------
diff --git a/spec/grammar.md b/spec/grammar.md
index 8c394579..b672243e 100644
--- a/spec/grammar.md
+++ b/spec/grammar.md
@@ -34,13 +34,11 @@ Starting at the highest-order objects, modifiers have fairly simple syntax. In m
| Operand _mod2_ # Left partial application
| _m ASGN _m1Expr
-Functions can be formed by fully applying modifiers, as trains, or with the return token `→`, which behaves syntactically like a 1-modifier whose operand must be an identifier. Modifiers are left-associative, so that the left operand (`Operand`) can include modifier applications but the right operand (`subject | Func`) cannot. Trains are right-associative, but bind less tightly than modifiers. Assignment is not allowed in the top level of a train: it must be parenthesized.
+Functions can be formed by fully applying modifiers or as trains. Modifiers are left-associative, so that the left operand (`Operand`) can include modifier applications but the right operand (`subject | Func`) cannot. Trains are right-associative, but bind less tightly than modifiers. Assignment is not allowed in the top level of a train: it must be parenthesized.
Derv = Func
| Operand _mod1
| Operand _mod2_ ( subject | Func )
- | Return
- Return = ( NAME | "𝕊" | "𝕣" ) "→"
Operand = subject
| Derv
Fork = Derv
diff --git a/spec/scope.md b/spec/scope.md
index 26b924c8..893348fb 100644
--- a/spec/scope.md
+++ b/spec/scope.md
@@ -43,7 +43,3 @@ When a body in a block is evaluated, it creates a *namespace*, which contains a
The first access to a variable must be made by its definition (this also means it sets the variable). If a different instance of its identifier accesses it first, then an error results. This can happen because every scope contained in a particular scope sees all the definitions it uses, and such a scope could be called before the definition is run. Because of conditional execution, this property must be checked at run time in general; however, in cases where it is possible to statically determine that a program will always violate it, a BQN instance can give an error at compile time rather than run time.
A namespace defines a mapping from names to variables: if the given name is shared by an exported identifier in the body used to create that namespace, then that name maps to the variable corresponding to that identifier. The mapping is undefined for other names.
-
-## Returns
-
-The name `NAME | "𝕊" | "𝕣"` in a `Return` node is resolved exactly like any other identifier. Following resolution, the block that defines the identifier must not be a namespace block (export variables or contain an `EXPORT` statement). Furthermore, if it is a `NAME`, then its definition must be an internal name for a containing block: `s` in `brSub`, `F` in `FuncHead` or `FMain`, `_m` in `Mod1H1` or `_mMain`, or `_c_` in `Mod2H1` or `_cMain_`. When reached, the `Return` node's identifier is not accessed; instead, it is used to indicate the namespace that contains it, and through this the block evaluation that created that namespace.
diff --git a/spec/token.md b/spec/token.md
index 522179c8..12d04679 100644
--- a/spec/token.md
+++ b/spec/token.md
@@ -25,6 +25,6 @@ Otherwise, a single character forms a token. Only the specified set of character
| Primitive 1-Modifier | `` ˙˜˘¨⌜⁼´˝` ``
| Primitive 2-Modifier | `∘○⊸⟜⌾⊘◶⎉⚇⍟⎊`
| Special name | `𝕨𝕩𝕗𝕘𝕤𝕎𝕏𝔽𝔾𝕊`
-| Punctuation | `←⇐↩→(){}⟨⟩‿⋄,.` and newline
+| Punctuation | `←⇐↩(){}⟨⟩‿⋄,.` and newline
In the BQN [grammar specification](grammar.md), the three primitive classes are grouped into terminals `Fl`, `_ml`, and `_cl`, while the punctuation characters are identified separately as keywords such as `"←"`. The special names are handled specially. The uppercase versions `𝕎𝕏𝔽𝔾𝕊` and lowercase versions `𝕨𝕩𝕗𝕘𝕤` are two spellings of the five underlying inputs and function.