Is it possible to define new types in newlisp?
no two symbols in newLISP point to the same, except when pointing to symbols. So if you do:
(set 'x "hello"
(set 'y x) => "hello"
those are two different memory pieces containing "hello". But when doing
(set 's "content of s")
(set 'x 's) => s
(set 'y x) => s
(eval x) => "content of s"
(eval y) => "content of s"
The two strings are the identical piece of memory, as you can show:
(pop s) => "c"
(eval x) => "ontent of s"
(eval y) => "ontent of s"
(pop (evall x)) = "o"
(eval y) => "ntent of s"
Quote
Is there a way to discover symbols that point to a value?
yes, you still could do this:
(set 'x "hello")
(set 'y "hello")
(filter (fn (s) (= "hello" (eval s))) (symbols)) => (x y)
but of course this is just a linear lookup, nothing is indexed here.
Quote
Ooo! A reverse lookup! Interesting idea. Lutz?
yes that would be possible, you could create a reversed index:
(set 'x "hello")
(set 'y 123)
; create a reverse index in Idx
(map (fn (s) (set (sym (string (eval s)) 'Idx) s )) (symbols))
(context Idx "hello") => x
(context Idx "123") => y
Lutz