aboutsummaryrefslogtreecommitdiff
path: root/docs/spec
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-08-23 21:47:50 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-08-23 21:47:50 -0400
commit797ac909fe0e34ec3408164c789203edfea0d55b (patch)
tree4ebb9e4de065f45eb253c5e59362e45b12bd0c2a /docs/spec
parent479974d584a44967a5a3fd69e439ec2fed3dd292 (diff)
Draft •NewBQN spec
Diffstat (limited to 'docs/spec')
-rw-r--r--docs/spec/system.html32
1 files changed, 32 insertions, 0 deletions
diff --git a/docs/spec/system.html b/docs/spec/system.html
index d4b56cf4..64200f27 100644
--- a/docs/spec/system.html
+++ b/docs/spec/system.html
@@ -37,11 +37,43 @@
<td><code><span class='Function'>•Using</span></code></td>
<td>Import all values from the argument namespace</td>
</tr>
+<tr>
+<td><code><span class='Function'>•NewBQN</span></code></td>
+<td>Create a BQN-like evaluation function with options <code><span class='Value'>𝕩</span></code></td>
+</tr>
</tbody>
</table>
<p>The left argument to any evaluator (<code><span class='Function'>•BQN</span></code>, <code><span class='Function'>•Eval</span></code>, <code><span class='Function'>•ScopedEval</span></code>, result of <code><span class='Function'>•MakeREPL</span></code>), if given, is a list of up to three elements, giving a prefix of <code><span class='Value'>•state</span></code> (see next section) during evaluations of that function. Thus <code><span class='Bracket'>⟨</span><span class='String'>&quot;&quot;</span><span class='Separator'>,</span><span class='String'>&quot;xyz&quot;</span><span class='Bracket'>⟩</span><span class='Function'>•BQN</span><span class='String'>&quot;•name&quot;</span></code> returns <code><span class='String'>&quot;xyz&quot;</span></code>.</p>
<p>The effect of <code><span class='Function'>•Eval</span></code> should be the same as if its argument were written as source code in the scope where <code><span class='Function'>•Eval</span></code> appears. It can define variables, and modify those in the current scope or a parent.</p>
<p><code><span class='Function'>•ScopedEval</span></code> creates as new scope for evaluation as it is loaded. Other than its syntactic role, it is effectively equivalent to <code><span class='Brace'>{</span><span class='Function'>•Eval</span><span class='Brace'>}</span></code>. Parent scopes are visible from the created scope; to make a scope without this property use <code><span class='Function'>•BQN</span><span class='String'>&quot;•Eval&quot;</span></code> or <code><span class='Function'>•BQN</span><span class='String'>&quot;•ScopedEval&quot;</span></code>.</p>
+<p><code><span class='Function'>•NewBQN</span></code> accepts a namespace <code><span class='Value'>𝕩</span></code>. The following options are specified if supported:</p>
+<table>
+<thead>
+<tr>
+<th>Option</th>
+<th>Values (default first)</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td><code><span class='Value'>repl</span></code></td>
+<td><code><span class='String'>&quot;none&quot;</span></code>, <code><span class='String'>&quot;strict&quot;</span></code>, <code><span class='String'>&quot;loose&quot;</span></code></td>
+</tr>
+<tr>
+<td><code><span class='Value'>scope</span></code></td>
+<td><code><span class='String'>&quot;none&quot;</span></code>, <code><span class='String'>&quot;read&quot;</span></code>, <code><span class='String'>&quot;modify&quot;</span></code></td>
+</tr>
+<tr>
+<td><code><span class='Value'>primitives</span></code></td>
+<td>List of glyph-value pairs; default <code><span class='Bracket'>⟨⟩</span></code></td>
+</tr>
+<tr>
+<td><code><span class='Value'>retain</span></code></td>
+<td><code><span class='String'>&quot;all&quot;</span></code>, <code><span class='String'>&quot;unique&quot;</span></code>, <code><span class='String'>&quot;none&quot;</span></code></td>
+</tr>
+</tbody>
+</table>
+<p>The option <code><span class='Value'>repl</span></code> indicates how variables are retained across calls: with &quot;none&quot; they are not saved; with &quot;strict&quot;, they are saved and can't be redefined; and with &quot;loose&quot; they may be redefined. <code><span class='Value'>scope</span></code> indicates allowed interaction with the scope in which <code><span class='Function'>•NewBQN</span></code> is <em>called</em> (not loaded): with &quot;read&quot; variables may be read and with &quot;modify&quot; they may be read or modified. <code><span class='Value'>primitives</span></code> indicates primitives to be added in this copy of BQN. Each primitive uses the glyph and value given. The value must have an operation type and its type determines the primitive's role. <code><span class='Value'>retain</span></code> indicates which primitives from the current running BQN should be kept. With &quot;all&quot;, an error is given if <code><span class='Value'>primitives</span></code> redefines an existing primitive, but with &quot;unique&quot; primitives may be redefined.</p>
<h2 id="scripts"><a class="header" href="#scripts">Scripts</a></h2>
<table>
<thead>