From 2abb2a9ea25bfa4065eb374d1e2ff9d3669b75f4 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Fri, 9 Oct 2020 10:15:31 -0400 Subject: =?UTF-8?q?Add=20=E2=87=90=20to=20syntax=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/doc/syntax.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'docs/doc') diff --git a/docs/doc/syntax.html b/docs/doc/syntax.html index 0a6aab58..df063677 100644 --- a/docs/doc/syntax.html +++ b/docs/doc/syntax.html @@ -41,6 +41,10 @@ Define + +Export + + Change @@ -145,6 +149,16 @@ a ¯3 +

Exports

+

The double arrow is used to export variables from an immediate block or file. It can only be used in these contexts, and not in function or modifier blocks. There are two ways to export variables. First, in the variable definition can be replaced with to export the variable as it's defined. Second, an export statement consisting of an assignment target followed by with nothing to the right exports the variables in the assignment target and does nothing else. Export statements can be placed anywhere in the relevant program or body, including before declaration or on the last line, and a given variable can be exported any number of times.

+
a:alias, b, c:c0c1, b:b2{
+  bc   # Non-definition exports can go anywhere
+  a2    # Define and export
+  b1+a
+  cb"str"
+}
+
+

A block with exports is a namespace block, and in versions of BQN without first-class namespaces it can only be used as part of a destructuring assignment. This assignment's target is a list where each element specifies one of the names exported by the block and what it should be assigned to. The element can be either a single name (such as b above), which gives both, or a combination of a name, then :, then the assignment target. If : is never used, the names can be given as a strand with . To use : for aliases, bracket syntax ⟨⟩ is needed. Imported names can be repeated and can be spelled with any role (the role is ignored).

Lists and blocks

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 function. 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.

-- cgit v1.2.3