diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2022-11-18 22:10:59 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2022-11-18 22:10:59 -0500 |
| commit | e7f09d54e76d61709763dcaf1b3081812d88fe46 (patch) | |
| tree | db3a336c207bbfd34bf09e8e2f1ea2ccfa12e7e2 /docs/doc/block.html | |
| parent | e42111e4dfc2fac9f99b053fd3cd65cd6e11259f (diff) | |
Move introduction of the optional-function rule to main header section, not multiple bodies
Diffstat (limited to 'docs/doc/block.html')
| -rw-r--r-- | docs/doc/block.html | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/docs/doc/block.html b/docs/doc/block.html index cfffe895..115f47ec 100644 --- a/docs/doc/block.html +++ b/docs/doc/block.html @@ -184,6 +184,7 @@ <h3 id="special-names-in-headers"><a class="header" href="#special-names-in-headers">Special names in headers</a></h3> <p>Any element of a function or modifier header can be left nameless by using the corresponding special name in that position, instead of an identifier. For example, the header <code><span class='Value'>π¨</span> <span class='Function'>π½</span><span class='Modifier2'>_π£_</span><span class='Function'>πΎ</span> <span class='Value'>π©</span><span class='Head'>:</span></code> incorporates as much vagueness as possible. It indicates a deferred 2-modifier, but provides no other information.</p> <p>The name <code><span class='Value'>π¨</span></code> in this context can refer to either a left argument or no left argument, allowing a header with arguments to be used even for an ambiguous function. Recall that <code><span class='Value'>π¨</span></code> is the only token other than <code><span class='Nothing'>Β·</span></code> that can have no value. If an identifier or list is given as the left argument, then the function must be called with a left argument.</p> +<p>If a header consists of <code><span class='Function'>π</span></code> with one argument, like <code><span class='Function'>π</span> <span class='Value'>a</span><span class='Ligature'>βΏ</span><span class='Value'>b</span><span class='Head'>:</span></code> or <code><span class='Function'>π</span><span class='Value'>π©</span><span class='Head'>:</span></code>, the <code><span class='Function'>π</span></code> can be left off. See <a href="#case-headers">case headers</a> below for examples. The exception is if the argument is a plain name, as in <code><span class='Function'>π</span> <span class='Value'>arg</span><span class='Head'>:</span></code>, because the header <code><span class='Value'>arg</span><span class='Head'>:</span></code> is a label for an immediate block as described in the next section.</p> <h3 id="short-headers"><a class="header" href="#short-headers">Short headers</a></h3> <p>A header can also be a plain name with no inputs, called a <em>label</em>. A label specifies the type of the block and gives an internal name that can be used to refer to it, but doesn't specify the inputs.</p> <pre><span class='Brace'>{</span> <span class='Value'>b</span><span class='Head'>:</span> <span class='Comment'># Block @@ -223,7 +224,7 @@ <span class='Error'>Error: No header matched arguments</span> </pre> <h3 id="case-headers"><a class="header" href="#case-headers">Case headers</a></h3> -<p>A special rule allows for convenient case-matching syntax for one-argument functions. In any function header with one argument, the function name can be omitted as long as the argument is <em>not</em> a plain identifierβit must be <code><span class='Value'>π©</span></code> or a compound value like a list to distinguish it from an immediate block label.</p> +<p>The optional <code><span class='Function'>π</span></code> rule makes for convenient case-matching syntax in one-argument functions.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=YeKGkGLihpAib3V0ZXIiClRlc3Qg4oaQIHsKICAiYWJjIjogInN0cmluZyIgOwogIOKfqDIsYuKfqTog4oy98J2VqSAgICAgICA7CiAgNTogICAgICJudW1iZXIiIDsKICDwnZWpOiAgICAgImRlZmF1bHQiCn0KVGVzdCA1">βοΈ</a><pre> <span class='Function'>Test</span> <span class='Gets'>β</span> <span class='Brace'>{</span> <span class='String'>"abc"</span><span class='Head'>:</span> <span class='String'>"string"</span> <span class='Head'>;</span> <span class='Bracket'>β¨</span><span class='Number'>2</span><span class='Separator'>,</span><span class='Value'>b</span><span class='Bracket'>β©</span><span class='Head'>:</span> <span class='Function'>β½</span><span class='Value'>π©</span> <span class='Head'>;</span> |
