From 1a5d020366463e8f1514f7ee9d181a0510593a51 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Mon, 27 Dec 2021 21:22:26 -0500 Subject: Compiler requires a complete Decompose implementation to run --- docs/implementation/vm.html | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'docs/implementation') diff --git a/docs/implementation/vm.html b/docs/implementation/vm.html index 6d6df758..07fd6e95 100644 --- a/docs/implementation/vm.html +++ b/docs/implementation/vm.html @@ -711,7 +711,7 @@ -

To define the final two functions, call the second returned element as a function, with argument DecomposePrimInd. The function PrimInd gives the index of 𝕩 in the list of all primitives (defined as glyphs in pr.bqn), or the length of the runtime if 𝕩 is not a primitive. The two functions are only needed for computing inferred properties, and are defined by default so that every value is assumed to be a primitive, and PrimInd performs a linear search over the returned runtime. If the runtime is used directly, then this means that without setting DecomposePrimInd, function inferred properties will work slowly and for primitives only; if values from the runtime are wrapped then function inferred properties will not work at all.

+

To define the final two functions, call the second returned element as a function, with argument DecomposePrimInd. The function PrimInd gives the index of 𝕩 in the list of all primitives (defined as glyphs in pr.bqn), or the length of the runtime if 𝕩 is not a primitive. The two functions are only needed for computing inferred properties, and are defined by default so that every value is assumed to be a primitive, and PrimInd performs a linear search over the returned runtime. If the runtime is used directly, then this means that without setting DecomposePrimInd, function inferred properties will work slowly and for primitives only; if values from the runtime are wrapped then function inferred properties will not work at all. The compiler uses Under with compound right operands, so Decompose is needed to self-host.

Remember that + and - can also work on characters in some circumstances, under the rules of affine characters. Other arithmetic functions should only accept numbers. = must work on any atoms including functions and modifiers. must work on numbers and characters.

GroupLen and GroupOrd

GroupLen and GroupOrd, short for Group length and Group order, are used to implement Group () and also to grade small-range lists and invert permutations (the inverse of a permutation p is 1¨GroupOrd p). Each of these only needs to work on lists of integers. Shown below are efficient implementations using BQN extended with the notation (il) Fn x meaning l Fnx(i) l, where Fn is if omitted. Since these special assignments only change one element of l, each can be a fast constant-time operation.

@@ -748,7 +748,7 @@

The following steps give a working BQN system, assuming a working VM and core runtime:

-- cgit v1.2.3