aboutsummaryrefslogtreecommitdiff
path: root/docs/implementation/vm.html
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2022-02-09 11:02:51 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2022-02-09 11:02:51 -0500
commit31f4966a79feb3ca064106a4b269d6ef62085cbb (patch)
tree4a9603bd8de4303e5a8b7ab329f736984786f2ec /docs/implementation/vm.html
parentcc9006c6703f37f5e3033a4d27eaef6ca5dce4ac (diff)
Depth ¯1 doesn't really indicate shadowing, since no new variable is created
Diffstat (limited to 'docs/implementation/vm.html')
-rw-r--r--docs/implementation/vm.html4
1 files changed, 2 insertions, 2 deletions
diff --git a/docs/implementation/vm.html b/docs/implementation/vm.html
index 7a9db034..ba5731db 100644
--- a/docs/implementation/vm.html
+++ b/docs/implementation/vm.html
@@ -736,11 +736,11 @@
<li><strong>Runtime</strong>: list of primitive values; see <a href="#runtime">previous section</a></li>
<li><strong>System</strong>: function that takes a list of strings and returns corresponding system values</li>
<li><strong>Variables</strong>: names of existing variables in the scope</li>
-<li><strong>Depths</strong>: lexical depth of these variables (default <code><span class='Number'>0</span></code>; <code><span class='Number'>¯1</span></code> for depth 0 but allowing shadowing)</li>
+<li><strong>Depths</strong>: lexical depth of these variables (default <code><span class='Number'>0</span></code>; <code><span class='Number'>¯1</span></code> for depth 0 but allowing redefinition)</li>
</ul>
<p>If <code><span class='Value'>𝕨</span></code> has length greater than 4 it's assumed to be the runtime only. If the length is less than 4, empty defaults that don't define any values are used for the missing arguments.</p>
<p>The system-value function is passed a list of unique normalized names, meaning that each name is lowercase and contains no underscores. It should return a corresponding list of system values. Because system values are requested on each program run, a function that has access to context such as <code><span class='Value'>•path</span></code> can construct appropriate system values on demand.</p>
-<p>The variable list is used to create REPLs, but has other uses as well, such as allowing execution to take place within a surrounding scope. It consists of a list of normalized names. The corresponding depth list indicates the lexical depth of each of these, with 0 and -1 indicating that the variable should exist directly in the top-level scope. A typical interactive REPL uses only the value -1, because it allows variables to be shadowed. It maintains a single top-level environment to be used for all evaluations. When the programmer enters a line, it's compiled, then the environment and list of top-level names is extended according to the result.</p>
+<p>The variable list is used to create REPLs, but has other uses as well, such as allowing execution to take place within a surrounding scope. It consists of a list of normalized names. The corresponding depth list indicates the lexical depth of each of these, with 0 and -1 indicating that the variable should exist directly in the top-level scope. A typical interactive REPL uses only the value -1, because it allows variables to be redefined—that is, definition with <code><span class='Gets'>←</span></code> won't fail but instead modify an existing variable. It maintains a single top-level environment to be used for all evaluations. When the programmer enters a line, it's compiled, then the environment and list of top-level names is extended according to the result.</p>
<h2 id="assembly"><a class="header" href="#assembly">Assembly</a></h2>
<p>The full BQN implementation is made up of the two components above—virtual machine and core runtime—and the compiled runtime, compiler, and formatter. Since the compiler unlikely to work right away, I suggest initially testing the virtual machine on smaller pieces of code compiled by an existing, working, BQN implementation.</p>
<p>BQN sources can be compiled with <a href="https://github.com/mlochbaum/BQN/blob/master/implementation/../src/cjs.bqn">cjs.bqn</a>. It has two modes. If given a command-line argument <code><span class='Value'>r</span></code>, <code><span class='Value'>c</span></code>, or <code><span class='Value'>fmt</span></code>, it compiles one of the source files. With any other command-line arguments, it will compile each one, and format it as a single line of output. The output is in a format designed for Javascript. VMs in other languages generally copy and modify cjs.bqn to work with the new language (for example cc.bqn in CBQN).</p>