From 6dd5088519453bcad5f367b3c6dd3cfeb0e9cd5c Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Wed, 3 Mar 2021 22:17:06 -0500 Subject: Documentation on namespaces --- doc/syntax.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'doc/syntax.md') diff --git a/doc/syntax.md b/doc/syntax.md index 88434621..7a0b5eb3 100644 --- a/doc/syntax.md +++ b/doc/syntax.md @@ -84,6 +84,8 @@ Assignment can be used inline in an expression, and its result is always the val ### Exports +See [namespaces](namespace.md): this section is a little out of date. + 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. ⟨alias⇐a, b, c0‿c1⇐c, b2⇐b⟩←{ @@ -93,7 +95,7 @@ The double arrow `⇐` is used to export variables from an immediate block or fi c←b‿"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). +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 the assignment target, then `⇐`, then a name. 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 -- cgit v1.2.3