bel icon indicating copy to clipboard operation
bel copied to clipboard

Make sure manual mutation of the globals work even with hash lookup

Open masak opened this issue 5 years ago • 1 comments

We're about to merge #194, but even after that it's possible (and legal) for someone to manually mutate the entries of the list of globals.

(tbd: make examples of changing something that's already there, of adding something manually, and of deleting something — these can then be turned into tests)

I think the appropriate fix here is to always present the entries of the list of globals as a special "caretaker object".

As an extra bonus, that should allow us to only reify the list of globals (that is, both the cons cells of the list itself, and the key-value cons pairs) unless someone manually accesses that list with cdr or id. That doesn't have to happen as part of fixing this issue, though.

masak avatar Jul 11 '20 08:07 masak

I found a nice test case to run:

> (do (set g globe) t)
t
> (set L 0)
0
> (while g (do (prn (car (car g))) (++ L) (prn L) (zap cdr g)))

This prints all the names of the globals, and an increasing count. Currently it's too slow, mostly because numbers are slow.

masak avatar Jul 11 '20 16:07 masak