diff options
Diffstat (limited to 'docs/doc/extensions.html')
| -rw-r--r-- | docs/doc/extensions.html | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/docs/doc/extensions.html b/docs/doc/extensions.html new file mode 100644 index 00000000..69406354 --- /dev/null +++ b/docs/doc/extensions.html @@ -0,0 +1,35 @@ +<head><link href="../style.css" rel="stylesheet"/></head> +<div class="nav"><a href="https://github.com/mlochbaum/BQN">BQN</a></div> +<h1 id="bqn-extensions">BQN extensions</h1> +<p>This page describes features that are not part of the core BQN specification, but may be specified in the future. If specified, these features would be optional, so that an implementation could choose to support them or not.</p> +<h2 id="complex-numbers">Complex numbers</h2> +<p>These are fairly common in APL dialects and could be useful in BQN as well.</p> +<h2 id="sets-and-dictionaries">Sets and dictionaries</h2> +<p>Sets are unordered collections of distinct values. Dictionaries have a set of keys and associate each key with a corresponding value. These types are a natural fit for the data in some cases; while they can be represented using arrays of keys and values, using the right type can lead to cleaner and faster algorithms.</p> +<p>The following glyphs are added for the dictionary and set literal notation.</p> +<table> +<thead> +<tr> +<th>Glyph(s)</th> +<th>Meaning</th> +</tr> +</thead> +<tbody> +<tr> +<td><code><span class='Value'>:</span></code></td> +<td>Key/value separator for dictionaries</td> +</tr> +<tr> +<td><code><span class='Value'>⦃⦄</span></code></td> +<td>Set</td> +</tr> +</tbody> +</table> +<p>Set notation matches the bracketed list notation with the angle brackets changed to double-struck curly brackets <code><span class='Value'>⦃⦄</span></code>, but there is no ligature notation for sets.</p> +<p>Dictionaries use angle brackets <code><span class='Bracket'>⟨⟩</span></code> like lists, but instead of expressions there are pairs of expressions separated by <code><span class='Value'>:</span></code>. The first expression evaluates to the key and the second to the corresponding value. The empty dictionary is written <code><span class='Bracket'>⟨</span><span class='Value'>:</span><span class='Bracket'>⟩</span></code>.</p> +<p>Dictionaries and sets should be supported their own set of primitive operations like arrays are. The glyphs <code><span class='Value'>∪⊂⊃⊆⊇</span></code> from mathematics are unused for this reason: they could be wanted for set operations.</p> +<h2 id="namespaces-and-symbols">Namespaces and symbols</h2> +<p>Sometimes it is useful to have a mutable type, particularly if a part of the program should maintain its own state over the course of execution. The <a href="https://en.wikipedia.org/wiki/Closure_(computer_programming)">closures</a> required as part of a complete lexical scoping implementation actually allow something like this. If a function defines and returns an explicit function, then that function can read and change variables in its environment. As the environment includes the scope created to execute the outer function, calling the outer function creates a mutable environment that can be indirectly accessed through the returned function.</p> +<p>A namespace would allow such an environment to be directly accessed and manipulated. While it's possible there would be facilities to create a namespace, a simpler mechanism is simply to add a primitive that returns the current scope as a variable. This scope would then behave the same way as a returned function's environment, and would allow member access by a dot-like syntax.</p> +<p>A symbol is a variable representing a name in the program. Symbols would make it easier to interact with namespaces dynamically.</p> + |
