diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2023-01-26 20:15:30 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2023-01-26 20:15:30 -0500 |
| commit | d4e2b6542548cd2b60815185aaf021d44dca1ff7 (patch) | |
| tree | 554ae534cd13af7762d889bb41dc40446b8d0c0f | |
| parent | fe5ed9ad1a2c3cb2b02c4d36077f6acbddc5a11b (diff) | |
More explicit documentation about roles in a few places
| -rw-r--r-- | doc/expression.md | 2 | ||||
| -rw-r--r-- | doc/fromJ.md | 12 | ||||
| -rw-r--r-- | doc/namespace.md | 2 | ||||
| -rw-r--r-- | docs/doc/expression.html | 2 | ||||
| -rw-r--r-- | docs/doc/fromJ.html | 5 | ||||
| -rw-r--r-- | docs/doc/namespace.html | 2 |
6 files changed, 15 insertions, 10 deletions
diff --git a/doc/expression.md b/doc/expression.md index 5359a672..0f6eeccb 100644 --- a/doc/expression.md +++ b/doc/expression.md @@ -48,7 +48,7 @@ The four roles are **subject**, **function**, **1-modifier**, and **2-modifier** Primitive tokens, since they have a fixed value, always have a role that matches their type. They're functions by default, as the modifiers have glyphs that fit specific patterns. 1-modifiers have superscript glyphs, and 2-modifiers have glyphs with an unbroken circle—that is, one without a line through it, excluding functions `⌽` and `⍉`. -Variable names can be written in any case and with underscores added, and these changes don't affect what [identifier](lexical.md) the name refers to. `ab`, `aB`, `AB`, and `_a_B_` are all the same variable. However, the spelling—specifically the first and last characters—determine the variable's role. A lowercase first letter indicates a subject, and an uppercase first letter makes it a function. A leading underscore (regardless of the following character) indicates a 1-modifier, and both leading and trailing underscores makes a 2-modifier. +Variable names (including [namespace](namespace.md) fields) can be written in any case and with underscores added, and these changes don't affect what [identifier](lexical.md) the name refers to. `ab`, `aB`, `AB`, and `_a_B_` are all the same variable. However, the spelling—specifically the first and last characters—determine the variable's role. A lowercase first letter indicates a subject, and an uppercase first letter makes it a function. A leading underscore (regardless of the following character) indicates a 1-modifier, and both leading and trailing underscores makes a 2-modifier. Besides these, character, string, and [array literals](arrayrepr.md#array-literals) always have a subject role, and the role of a [block](block.md) is determined by its type, which depends either on the header it has or which special variables it uses. If headerless, a block is a subject if it has no special names, but a `𝕨` or `𝕩` makes it at least a function, an `𝔽` makes it a 1- or 2-modifier, and a `𝔾` always makes it a 2-modifier. diff --git a/doc/fromJ.md b/doc/fromJ.md index efe976d6..d2fed75d 100644 --- a/doc/fromJ.md +++ b/doc/fromJ.md @@ -22,12 +22,12 @@ BQN uses "[depth](depth.md)" rather than "boxing level". BQN gives atoms depth 0 In J, the part of speech is an inherent property of a value, while in BQN it's determined by how the value is used in a particular expression, and can be different from the value's type. See [context-free grammar](context.md). -| J part of speech | BQN role | -|---------------------|------------| -| Noun | Subject | -| Verb | Function | -| Adverb | 1-modifier | -| Conjunction | 2-modifier | +| J part of speech | BQN role | Spelling | +|---------------------|------------|-------------| +| Noun | Subject | `lowerCase` | +| Verb | Function | `UpperCase` | +| Adverb | 1-modifier | `_leading` | +| Conjunction | 2-modifier | `_both_` | ## Syntax diff --git a/doc/namespace.md b/doc/namespace.md index 896b2ffb..d7fc4562 100644 --- a/doc/namespace.md +++ b/doc/namespace.md @@ -46,7 +46,7 @@ There are also two ways to get values out of a namespace, such as `example` defi {n⇐7}.n -The part on the left can be anything with a subject role, although it will often need to be parenthesized because `.` has higher precedence than any operator. This allows it to be chained like `a.b.c` if a namespace has a value that is also a namespace (and so on). +The part on the left can be anything with a subject [role](expression.md#syntactic-role), although it will often need to be parenthesized because `.` has higher precedence than any operator. So it can be chained like `a.b.c` if a field has a value that is also a namespace (and so on). The overall role is determined by the last name: for example `•math.Sin` has a function role. Second, a namespace might be used in a [destructuring](expression.md#destructuring) assignment like the one below. This assignment's target looks like a list, where each entry specifies one of the names exported by the block and what it should be assigned to. The element can be either a single name, like `b`, which gives both, or an aliasing expression like `b2⇐b`. In this case, the value `b` from the namespace is used, but it's given the name `b2` instead of `b`. Imported names can be repeated—but the variable names defined can't be—and all the names can be spelled with any role (the role is ignored). diff --git a/docs/doc/expression.html b/docs/doc/expression.html index f8c40256..06d66ccf 100644 --- a/docs/doc/expression.html +++ b/docs/doc/expression.html @@ -103,7 +103,7 @@ </tbody> </table> <p>Primitive tokens, since they have a fixed value, always have a role that matches their type. They're functions by default, as the modifiers have glyphs that fit specific patterns. 1-modifiers have superscript glyphs, and 2-modifiers have glyphs with an unbroken circle—that is, one without a line through it, excluding functions <code><span class='Function'>⌽</span></code> and <code><span class='Function'>⍉</span></code>.</p> -<p>Variable names can be written in any case and with underscores added, and these changes don't affect what <a href="lexical.html">identifier</a> the name refers to. <code><span class='Value'>ab</span></code>, <code><span class='Value'>aB</span></code>, <code><span class='Function'>AB</span></code>, and <code><span class='Modifier2'>_a_B_</span></code> are all the same variable. However, the spelling—specifically the first and last characters—determine the variable's role. A lowercase first letter indicates a subject, and an uppercase first letter makes it a function. A leading underscore (regardless of the following character) indicates a 1-modifier, and both leading and trailing underscores makes a 2-modifier.</p> +<p>Variable names (including <a href="namespace.html">namespace</a> fields) can be written in any case and with underscores added, and these changes don't affect what <a href="lexical.html">identifier</a> the name refers to. <code><span class='Value'>ab</span></code>, <code><span class='Value'>aB</span></code>, <code><span class='Function'>AB</span></code>, and <code><span class='Modifier2'>_a_B_</span></code> are all the same variable. However, the spelling—specifically the first and last characters—determine the variable's role. A lowercase first letter indicates a subject, and an uppercase first letter makes it a function. A leading underscore (regardless of the following character) indicates a 1-modifier, and both leading and trailing underscores makes a 2-modifier.</p> <p>Besides these, character, string, and <a href="arrayrepr.html#array-literals">array literals</a> always have a subject role, and the role of a <a href="block.html">block</a> is determined by its type, which depends either on the header it has or which special variables it uses. If headerless, a block is a subject if it has no special names, but a <code><span class='Value'>𝕨</span></code> or <code><span class='Value'>𝕩</span></code> makes it at least a function, an <code><span class='Function'>𝔽</span></code> makes it a 1- or 2-modifier, and a <code><span class='Function'>𝔾</span></code> always makes it a 2-modifier.</p> <p>The role of a compound expression, formed by applying an operation to some inputs, depends on the operation applied. This system is covered in the remaining sections below.</p> <h2 id="parentheses"><a class="header" href="#parentheses">Parentheses</a></h2> diff --git a/docs/doc/fromJ.html b/docs/doc/fromJ.html index 0486e60b..99107f88 100644 --- a/docs/doc/fromJ.html +++ b/docs/doc/fromJ.html @@ -19,24 +19,29 @@ <tr> <th>J part of speech</th> <th>BQN role</th> +<th>Spelling</th> </tr> </thead> <tbody> <tr> <td>Noun</td> <td>Subject</td> +<td><code><span class='Value'>lowerCase</span></code></td> </tr> <tr> <td>Verb</td> <td>Function</td> +<td><code><span class='Function'>UpperCase</span></code></td> </tr> <tr> <td>Adverb</td> <td>1-modifier</td> +<td><code><span class='Modifier'>_leading</span></code></td> </tr> <tr> <td>Conjunction</td> <td>2-modifier</td> +<td><code><span class='Modifier2'>_both_</span></code></td> </tr> </tbody> </table> diff --git a/docs/doc/namespace.html b/docs/doc/namespace.html index 8c4760af..87663860 100644 --- a/docs/doc/namespace.html +++ b/docs/doc/namespace.html @@ -37,7 +37,7 @@ <span class='Brace'>{</span><span class='Value'>n</span><span class='Gets'>⇐</span><span class='Number'>7</span><span class='Brace'>}</span><span class='Value'>.n</span> </pre> -<p>The part on the left can be anything with a subject role, although it will often need to be parenthesized because <code><span class='Value'>.</span></code> has higher precedence than any operator. This allows it to be chained like <code><span class='Value'>a.b.c</span></code> if a namespace has a value that is also a namespace (and so on).</p> +<p>The part on the left can be anything with a subject <a href="expression.html#syntactic-role">role</a>, although it will often need to be parenthesized because <code><span class='Value'>.</span></code> has higher precedence than any operator. So it can be chained like <code><span class='Value'>a.b.c</span></code> if a field has a value that is also a namespace (and so on). The overall role is determined by the last name: for example <code><span class='Value'>•math.</span><span class='Function'>Sin</span></code> has a function role.</p> <p>Second, a namespace might be used in a <a href="expression.html#destructuring">destructuring</a> assignment like the one below. This assignment's target looks like a list, where each entry specifies one of the names exported by the block and what it should be assigned to. The element can be either a single name, like <code><span class='Value'>b</span></code>, which gives both, or an aliasing expression like <code><span class='Value'>b2</span><span class='Gets'>⇐</span><span class='Value'>b</span></code>. In this case, the value <code><span class='Value'>b</span></code> from the namespace is used, but it's given the name <code><span class='Value'>b2</span></code> instead of <code><span class='Value'>b</span></code>. Imported names can be repeated—but the variable names defined can't be—and all the names can be spelled with any role (the role is ignored).</p> <pre><span class='Bracket'>⟨</span><span class='Value'>alias</span><span class='Gets'>⇐</span><span class='Value'>a</span><span class='Separator'>,</span> <span class='Value'>b</span><span class='Separator'>,</span> <span class='Value'>c0</span><span class='Ligature'>‿</span><span class='Value'>c1</span><span class='Gets'>⇐</span><span class='Value'>c</span><span class='Separator'>,</span> <span class='Value'>b2</span><span class='Gets'>⇐</span><span class='Value'>b</span><span class='Bracket'>⟩</span> <span class='Gets'>←</span> <span class='Value'>example</span> </pre> |
