From 4ac3f5940a89dcbc165479603689e02c29f50feb Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 23 Jun 2022 16:33:26 -0400 Subject: Document [] notation --- docs/doc/syntax.html | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'docs/doc/syntax.html') diff --git a/docs/doc/syntax.html b/docs/doc/syntax.html index 6312fbbd..a5c75b6e 100644 --- a/docs/doc/syntax.html +++ b/docs/doc/syntax.html @@ -58,11 +58,15 @@ ⟨⟩ -List (rank-1 array) +List + + +[] +Array -Strand (lightweight list syntax) +Strand (lightweight list syntax) {} @@ -182,13 +186,14 @@

The four roles (subject, function, two kinds of modifier) describe expressions, not values. When an expression is evaluated, the value's type doesn't have to correspond to its role, and can even change from one evaluation to another. An expression's role is determined entirely by its source code, so it's fixed.

Assignment arrows , , and store expression results in variables: and create new variables while modifies existing ones. The general format is Name Value, where the two sides have the same role. Additionally, lhs F rhs is a shortened form of lhs lhs F rhs and lhs F expands to lhs F lhs.

The double arrow is used for functionality relating to namespaces. It has a few purposes: exporting assignment namevalue, plain export name, and aliasing aliasfieldnamespace. A block that uses it for export returns a namespace rather than the result of its last statement. The other namespace-related bit of syntax is field access ns.field.

-

Lists and blocks

-

Lists and code blocks can both be represented as sequences of expressions in source code. They both have paired bracket representations, using ⟨⟩ for lists and {} for blocks, as well as a shortcut "stranding" notation using for lists.

+

Arrays and blocks

+

Arrays and code blocks can both be represented as sequences of expressions in source code. There are paired bracket representations, using ⟨⟩ for lists, [] for arrays, and {} for blocks, as well as a shortcut "stranding" notation using for lists.

Separators

The characters and , and newline are completely interchangeable and are used to separate expressions. An expression might be an element in a list or a line in a block. Empty sections—those that consist only of whitespace—are ignored. This means that any number of separators can be used between expressions, and that leading and trailing separators are also allowed. The expressions are evaluated in text order: left to right and top to bottom.

-

List notation

-

Full documentation

+

List and array notation

+

Full documentation

Lists (1-dimensional arrays) are enclosed in angle brackets ⟨⟩, with the results of the expressions in between being the list's elements. Lists of two elements or more can also be written with the ligature character . This character has higher binding strength than any part of an expression except . for namespace field access. If one of the elements is a compound expression, then it will need to be enclosed in parentheses.

+

Arrays, or at least non-empty ones with rank 1 or more, can be written with square brackets []. These work just like angle brackets but merge the elements so that they form cells of the result.

Blocks

Full documentation

Blocks are written with curly braces {} and can have a subject, function, or modifier role. The contents are any number of bodies separated by ;. Each body is a sequence of expressions to be evaluated in order, possibly with a header, followed by :, that sets the type and describes expected inputs. A body runs in its own environment according to the rules of lexical scoping. The result is either a namespace, if the body used , or the result of the last expression.

-- cgit v1.2.3