From e7f09d54e76d61709763dcaf1b3081812d88fe46 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Fri, 18 Nov 2022 22:10:59 -0500 Subject: Move introduction of the optional-function rule to main header section, not multiple bodies --- docs/doc/block.html | 3 ++- docs/doc/quick.html | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'docs') 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 @@

Special names in headers

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 𝕨 𝔽_𝕣_𝔾 𝕩: incorporates as much vagueness as possible. It indicates a deferred 2-modifier, but provides no other information.

The name 𝕨 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 𝕨 is the only token other than Β· 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.

+

If a header consists of π•Š with one argument, like π•Š aβ€Ώb: or π•Šπ•©:, the π•Š can be left off. See case headers below for examples. The exception is if the argument is a plain name, as in π•Š arg:, because the header arg: is a label for an immediate block as described in the next section.

Short headers

A header can also be a plain name with no inputs, called a label. 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.

{ b:   # Block
@@ -223,7 +224,7 @@
 Error: No header matched arguments
 

Case headers

-

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 not a plain identifierβ€”it must be 𝕩 or a compound value like a list to distinguish it from an immediate block label.

+

The optional π•Š rule makes for convenient case-matching syntax in one-argument functions.

↗️
    Test ← {
       "abc": "string" ;
       ⟨2,b⟩: βŒ½π•©       ;
diff --git a/docs/doc/quick.html b/docs/doc/quick.html
index 5b7061a9..64eefcd7 100644
--- a/docs/doc/quick.html
+++ b/docs/doc/quick.html
@@ -242,7 +242,7 @@
 

Going left to right, GVβ€ΏGS indicates destructuring assignment, which will expect a list of two values on the right and take it apart to assign the two names. The right hand side is the function {𝕏¨}Β¨ applied to a list.

{𝕏¨} is a block function, like Split but a lot shorter. It uses the uppercase 𝕏 instead of 𝕩, so that it treats 𝕩 as a function (it doesn't require it to be a function, though: see mixing roles). It adds an Each Β¨ onto its argument. This is used to convert the two functions in the list from functions that work on a namespaces to functions that work on a list of them.

The list is split across two lines, using newline as a separator instead of , or β‹„. Its second function {𝕩.spl} is simpler: it takes a namespace 𝕩 and gets the field named spl.

-

The first function is more complicated, because the argument namespace might or might not have an str field. The list-like notation ⟨s⇐str⟩ is another example of destructuring assignment, but this time it destructures a namespace, using an alias to give it a short name. This header leaves off the function name π•Š, using a special rule for one-argument functions. Arguments in headers are very similar to assignment targets, but if the destructuring doesn't match it tries the next body (if there is one) instead of giving an error. So if the argument is a namespace with an str field then {⟨s⇐str⟩:s;""} returns that field's value, and otherwise it returns "".

+

The first function is more complicated, because the argument namespace might or might not have an str field. The list-like notation ⟨s⇐str⟩ is another example of destructuring assignment, but this time it destructures a namespace, using an alias to give it a short name. This header leaves off the function name π•Š, using a special rule for one-argument functions. Arguments in headers are very similar to assignment targets, but if the destructuring doesn't match it tries the next body (if there is one) instead of giving an error. So if the argument is a namespace with an str field then {⟨s⇐str⟩:s;""} returns that field's value, and otherwise it returns "".

Assembly

Now that Split has defined Proc, GV (get value), and GS (get split), it's ready to do its work.

r ← Proc{Β»π”½Β¨βŠ’} 𝕩
-- 
cgit v1.2.3