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 --- doc/block.md | 4 +++- doc/quick.md | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/block.md b/doc/block.md index e4d32fa4..9e436490 100644 --- a/doc/block.md +++ b/doc/block.md @@ -157,6 +157,8 @@ Any element of a function or modifier header can be left nameless by using the c 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](#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. @@ -198,7 +200,7 @@ If no header is compatible, the call results in an error. ### 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" ; diff --git a/doc/quick.md b/doc/quick.md index fecee2a9..afb89519 100644 --- a/doc/quick.md +++ b/doc/quick.md @@ -230,7 +230,7 @@ Going left to right, `GV‿GS` indicates [destructuring assignment](expression.m The list is split across two lines, using newline as a [separator](token.md#separators) 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](namespace.md#imports) to give it a short name. This header leaves off the function name `𝕊`, using a [special rule](block.md#case-headers) 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](namespace.md#imports) to give it a short name. This header leaves off the function name `𝕊`, using a [special rule](block.md#special-names-in-headers) 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 -- cgit v1.2.3