From 31f4966a79feb3ca064106a4b269d6ef62085cbb Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Wed, 9 Feb 2022 11:02:51 -0500 Subject: =?UTF-8?q?Depth=20=C2=AF1=20doesn't=20really=20indicate=20shadowi?= =?UTF-8?q?ng,=20since=20no=20new=20variable=20is=20created?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/implementation/vm.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/implementation/vm.html') 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 @@
  • Runtime: list of primitive values; see previous section
  • System: function that takes a list of strings and returns corresponding system values
  • Variables: names of existing variables in the scope
  • -
  • Depths: lexical depth of these variables (default 0; ¯1 for depth 0 but allowing shadowing)
  • +
  • Depths: lexical depth of these variables (default 0; ¯1 for depth 0 but allowing redefinition)
  • If 𝕨 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.

    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 •path can construct appropriate system values on demand.

    -

    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.

    +

    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 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.

    Assembly

    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.

    BQN sources can be compiled with cjs.bqn. It has two modes. If given a command-line argument r, c, or fmt, 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).

    -- cgit v1.2.3