Defining types
Defining types
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:
those are two different memory pieces containing "hello". But when doing
The two strings are the identical piece of memory, as you can show:
but of course this is just a linear lookup, nothing is indexed here.
Lutz
Code: Select all
(set 'x "hello"
(set 'y x) => "hello"
Code: Select all
(set 's "content of s")
(set 'x 's) => s
(set 'y x) => s
(eval x) => "content of s"
(eval y) => "content of s"
Code: Select all
(pop s) => "c"
(eval x) => "ontent of s"
(eval y) => "ontent of s"
(pop (evall x)) = "o"
(eval y) => "ntent of s"
yes, you still could do this:Is there a way to discover symbols that point to a value?
Code: Select all
(set 'x "hello")
(set 'y "hello")
(filter (fn (s) (= "hello" (eval s))) (symbols)) => (x y)
yes that would be possible, you could create a reversed index:Ooo! A reverse lookup! Interesting idea. Lutz?
Code: Select all
(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