newLISP Fan Club

Forum => Anything else we might add? => Topic started by: Dmi on April 08, 2006, 08:27:51 AM

Title: (global) bug and question
Post by: Dmi on April 08, 2006, 08:27:51 AM
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))?
Title:
Post by: Lutz on April 08, 2006, 08:57:24 AM
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) "0001") 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
Title:
Post by: newdep on April 08, 2006, 09:01:18 AM
aaaaaaaa....your on the right track ;-)
Title:
Post by: Dmi on April 08, 2006, 09:52:32 AM
Thanks!
Title:
Post by: Dmi on April 08, 2006, 01:18:51 PM
Hmm... on my little endian (i belive ;-) Intel Celeron the test shows following:
> (pack "d" 1)
"0100"

so the rule for mask should be inversed:
(let (mask (if (= (pack ">d" 1) "0001") 0x00000200 0x02000000))
Title:
Post by: Lutz on April 08, 2006, 01:28:29 PM
actually it should be like this:



define (global? s)
        (let (mask (if (= (pack "d" 1) "0001") 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
Title:
Post by: Dmi on April 08, 2006, 01:39:31 PM
It does. Thanks again.