diff options
Diffstat (limited to 'docs/doc/syntax.html')
| -rw-r--r-- | docs/doc/syntax.html | 17 |
1 files changed, 11 insertions, 6 deletions
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 @@ </tr> <tr> <td><code><span class='Bracket'>⟨⟩</span></code></td> -<td><a href="#list-notation">List</a> (rank-1 array)</td> +<td><a href="#list-and-array-notation">List</a></td> +</tr> +<tr> +<td><code><span class='Bracket'>[]</span></code></td> +<td><a href="#list-and-array-notation">Array</a></td> </tr> <tr> <td><code><span class='Ligature'>‿</span></code></td> -<td><a href="#list-notation">Strand</a> (lightweight list syntax)</td> +<td><a href="#list-and-array-notation">Strand</a> (lightweight list syntax)</td> </tr> <tr> <td><code><span class='Brace'>{}</span></code></td> @@ -182,13 +186,14 @@ <p>The four <a href="expression.html#syntactic-role">roles</a> (subject, function, two kinds of modifier) describe expressions, not values. When an expression is evaluated, the value's <a href="types.html">type</a> 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.</p> <p><a href="expression.html#assignment">Assignment</a> arrows <code><span class='Gets'>←</span></code>, <code><span class='Gets'>↩</span></code>, and <code><span class='Gets'>⇐</span></code> store expression results in variables: <code><span class='Gets'>←</span></code> and <code><span class='Gets'>⇐</span></code> create new variables while <code><span class='Gets'>↩</span></code> modifies existing ones. The general format is <code><span class='Function'>Name</span> <span class='Gets'>←</span> <span class='Function'>Value</span></code>, where the two sides have the same role. Additionally, <code><span class='Value'>lhs</span> <span class='Function'>F</span><span class='Gets'>↩</span> <span class='Value'>rhs</span></code> is a shortened form of <code><span class='Value'>lhs</span> <span class='Gets'>↩</span> <span class='Value'>lhs</span> <span class='Function'>F</span> <span class='Value'>rhs</span></code> and <code><span class='Value'>lhs</span> <span class='Function'>F</span><span class='Gets'>↩</span></code> expands to <code><span class='Value'>lhs</span> <span class='Gets'>↩</span> <span class='Function'>F</span> <span class='Value'>lhs</span></code>.</p> <p>The double arrow <code><span class='Gets'>⇐</span></code> is used for functionality relating to <a href="namespace.html">namespaces</a>. It has a few purposes: exporting assignment <code><span class='Value'>name</span><span class='Gets'>⇐</span><span class='Value'>value</span></code>, plain export <code><span class='Value'>name</span><span class='Gets'>⇐</span></code>, and aliasing <code><span class='Bracket'>⟨</span><span class='Value'>alias</span><span class='Gets'>⇐</span><span class='Value'>field</span><span class='Bracket'>⟩</span><span class='Gets'>←</span><span class='Value'>namespace</span></code>. 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 <code><span class='Value'>ns.field</span></code>.</p> -<h2 id="lists-and-blocks"><a class="header" href="#lists-and-blocks">Lists and blocks</a></h2> -<p>Lists and code blocks can both be represented as sequences of expressions in source code. They both have paired bracket representations, using <code><span class='Bracket'>⟨⟩</span></code> for lists and <code><span class='Brace'>{}</span></code> for blocks, as well as a shortcut "stranding" notation using <code><span class='Ligature'>‿</span></code> for lists.</p> +<h2 id="arrays-and-blocks"><a class="header" href="#arrays-and-blocks">Arrays and blocks</a></h2> +<p>Arrays and code blocks can both be represented as sequences of expressions in source code. There are paired bracket representations, using <code><span class='Bracket'>⟨⟩</span></code> for lists, <code><span class='Bracket'>[]</span></code> for arrays, and <code><span class='Brace'>{}</span></code> for blocks, as well as a shortcut "stranding" notation using <code><span class='Ligature'>‿</span></code> for lists.</p> <h3 id="separators"><a class="header" href="#separators">Separators</a></h3> <p>The characters <code><span class='Separator'>⋄</span></code> and <code><span class='Separator'>,</span></code> 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.</p> -<h3 id="list-notation"><a class="header" href="#list-notation">List notation</a></h3> -<p><em><a href="arrayrepr.html#list-literals">Full documentation</a></em></p> +<h3 id="list-and-array-notation"><a class="header" href="#list-and-array-notation">List and array notation</a></h3> +<p><em><a href="arrayrepr.html#array-literals">Full documentation</a></em></p> <p>Lists (1-dimensional arrays) are enclosed in angle brackets <code><span class='Bracket'>⟨⟩</span></code>, 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 <code><span class='Ligature'>‿</span></code>. This character has higher binding strength than any part of an expression except <code><span class='Value'>.</span></code> for namespace field access. If one of the elements is a compound expression, then it will need to be enclosed in parentheses.</p> +<p>Arrays, or at least non-empty ones with rank 1 or more, can be written with square brackets <code><span class='Bracket'>[]</span></code>. These work just like angle brackets but <a href="couple.html#merge-and-array-theory">merge</a> the elements so that they form cells of the result.</p> <h3 id="blocks"><a class="header" href="#blocks">Blocks</a></h3> <p><em><a href="block.html">Full documentation</a></em></p> <p>Blocks are written with curly braces <code><span class='Brace'>{}</span></code> and can have a subject, function, or modifier role. The contents are any number of bodies separated by <code><span class='Head'>;</span></code>. Each body is a sequence of expressions to be evaluated in order, possibly with a header, followed by <code><span class='Head'>:</span></code>, that sets the type and describes expected inputs. A body runs in its own environment according to the rules of <a href="lexical.html">lexical scoping</a>. The result is either a <a href="namespace.html">namespace</a>, if the body used <code><span class='Gets'>⇐</span></code>, or the result of the last expression.</p> |
