lots of strange bugs when that file gets to large
sometimes it exists early when a function is too large or sometimes it has compile errors (leaving 0 items on stack) when the filename is a few chars longer....
need to compile allocation code instead of saving pointer as constant?
strings, cons, etc
nip
instead >r drop r>
…
-> the repl now compiles all forms before executing, so this is not as important.
(set a b (fn))
avoids overwriting common forth words so that a ‘forth shell’ can still be useful
symbols are currently in their own list but primitive functions are still global
=> not using wordlists, but all symbols are in a custom structure now
currently have to use forth number prefixes
oblists, actually
can be simply implemented as wordlists
like the ‘symbols’ wordlist that’s used for interning strings but expose the wordlists as a user type
(list 9 8 7 6 5 4 3 2 1 0) => 19 17 15 13 11 9 7 5 3 1 0 cons cons cons cons cons cons cons cons cons cons
instead do something like this: 19 17 15 13 11 9 7 5 3 1 0 10 Ncons
(def test-locals (x y) (var a 1) (var b 2) (var c 3) (var d 4) (var e 5) (var f 6) (println (list x y a b c d e f)) (test “locals 1” (equal? (list x y a b c d e f) (list 0 0 1 2 3 4 5 6 ))) (set x (+ x 1)) (set y (+ y 1)) (set a (+ a 1)) (set b (+ b 1)) (set c (+ c 1)) (set d (+ d 1)) (set e (+ e 1)) (set f (+ f 1)) (println (list x y a b c d e f)) (test “locals 2” (equal? (list x y a b c d e f) (list 1 1 2 3 4 5 6 7))))
(test-locals 0 0)
then fix s” xcons” for type-of
That’s expected, symbols are not interned by default
(eq? ‘defun ‘defun) => nil
(eq? defun defun) => t
(eq? (intern ‘defun) (intern ‘defun)) => t
The repl should evaluate the arguments in a function and assign back to var instead of interpreting the whole expression
or anything else that allocates space on the dictionary
maybe compile the _repl function at an offset?
or don’t put symbols on the dictionary
(type-of nil) => integer (type-of (read “nil”)) => symbol
happens intermittently
seems related to the file size somehow, works in repl, fails when unrelated lines are added or removed
fixed??