aboutsummaryrefslogtreecommitdiff
path: root/doc/syntax.md
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2020-08-31 22:02:40 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2020-08-31 22:04:19 -0400
commit85bd95ab4f2a40ccb1de042eaca64b9383a901ae (patch)
treec391cc3ee2fb9a1bd0f4fc8df30a8b4dd6b3b99b /doc/syntax.md
parentff0865870036fa767a041169cfd90243c52ec03b (diff)
Docs on the blocks
Diffstat (limited to 'doc/syntax.md')
-rw-r--r--doc/syntax.md8
1 files changed, 5 insertions, 3 deletions
diff --git a/doc/syntax.md b/doc/syntax.md
index 3f8b9800..9c34bc2a 100644
--- a/doc/syntax.md
+++ b/doc/syntax.md
@@ -16,13 +16,13 @@ Glyph(s) | Meaning
`()` | Expression grouping
`←` | [Define](#assignment)
`↩` | [Change](#assignment)
-`→` | Return
+`→` | [Return](block.md#returns)
`⋄,` or newline | Statement or element [separator](#separators)
`⟨⟩` | [List](#list-notation) (rank-1 array)
`‿` | [Strand](#list-notation) (lightweight list syntax)
`{}` | [Block](#blocks) such as a function definition
-`:` | Block header
-`;` | Block body separator
+`:` | [Block header](block.md#block-headers)
+`;` | [Block body separator](block.md#multiple-bodies)
`𝕨𝕎` | [Left argument](#blocks)
`𝕩𝕏` | [Right argument](#blocks)
`𝕤𝕊` | [Function self-reference](#blocks)
@@ -92,6 +92,8 @@ If added, [sets and dictionaries](extensions.md#sets-and-dictionaries) would als
### Blocks
+*[Full documentation](block.md)*
+
Blocks are written with curly braces `{}` and can be used to group expressions or define functions and modifiers. The contents are simply a sequence of expressions, where each is evaluated and the result of the last is returned in order to evaluate the block. This result can have any value, and its syntactic role in the calling context is determined by the normal rules: functions return subjects and modifiers return functions. Blocks have lexical scope.
The special names `𝕨` and `𝕩`, which stand for arguments, and `𝕗` and `𝕘`, which stand for operands, are available inside curly braces. Like ordinary names, the lowercase forms indicate subjects and the uppercase forms `𝕎𝕏𝔽𝔾` indicate functions. The type and syntactic role of the block is determined by its contents: a 2-modifier contains `𝕘`, a 1-modifier contains `𝕗` but not `𝕘`, and a function contains neither but does have one of `𝕨𝕩𝕤𝕎𝕏𝕊`. If no special names are present the block is an *immediate block* and is evaluated as soon as it appears, with the result having a subject role.