Page 1 of 1

newlisp crashing in 'new' function

Posted: Thu Dec 03, 2009 2:42 am
by itistoday
I've discovered an odd crash in newlisp 10.1.6 that's causing me grief:

Code: Select all

(new Class 'Foo)
(context Foo)
(constant 'NEWLISP64 (not (zero? (& (sys-info -1) 256))))

; comment out the line below and it doesn't crash
(constant 'get-ptr (if NEWLISP64 get-long get-int))
(context MAIN)

(new Foo 'Bar) ; crash!
What's going on, why is it crashing?

To get around this I tried placing the constant declarations outside the context Foo by context-qualifying them to be in the Foo class:

Code: Select all

(constant 'Foo:NEWLISP64 (not (zero? (& (sys-info -1) 256))))
But the function 'constant' won't let you do that (on a separate note, can that be changed too?).

Edit: this crash also happens if I use 'set' instead of 'constant'.

Re: newlisp crashing in 'new' function

Posted: Thu Dec 03, 2009 1:45 pm
by Lutz
this happens when doing 'new' on an alias built-in, in this case 'get-int/get-long'. This will be allowed in the next version.

As a workaround define the alias get-ptr in the MAIN level:

Code: Select all

(constant 'NEWLISP64 (not (zero? (& (sys-info -1) 256))))
(constant 'get-ptr (if NEWLISP64 get-long get-int))

(context 'Foo)
; get-ptr is now known here as a global built-in
(context MAIN)

(new Foo 'Bar) 

Re: newlisp crashing in 'new' function

Posted: Sat Dec 05, 2009 6:48 am
by itistoday
Thanks!