First, the bug:
dmi@dc:dmi$ newlisp
newLISP v.8.8.0-p2 on linux, execute 'newlisp -h' for more info.
> (global)
Segmentation fault
Second, a question:
How can I get a list of symbos of MAIN, that are maden global (either by
default or through (global sym))?
There is no streight way to get a list of all global symbols, but you could do the following hack for a 'global?' predicate which you could 'map' on to (symbols) and filter for not primitive?:
(define (global? s)
(let (mask (if (= (pack "d" 1) " 00 01") 0x02000000 0x00000200))
(= (& (get-int (last (dump s))) mask) mask)))
> (global? 'x)
nil
> (global 'x)
x
> (global? 'x)
true
>
This tests the global bit of a symbol type field and works on both: big-endian and little-endia systems.
Lutz
aaaaaaaa....your on the right track ;-)
Thanks!
Hmm... on my little endian (i belive ;-) Intel Celeron the test shows following:
> (pack "d" 1)
" 01 00"
so the rule for mask should be inversed:
(let (mask (if (= (pack ">d" 1) " 00 01") 0x00000200 0x02000000))
actually it should be like this:
define (global? s)
(let (mask (if (= (pack "d" 1) " 00 01") 0x02000000 0x00000200))
(= (& (get-int (last (dump s))) mask) mask)))
The '>' would always produce bigh-endian and the '<' always little-endian. So when testing for endianess, no '<' or '>' should be put. This should work for you.
Lutz
It does. Thanks again.