Page 1 of 1

Bug? 'delete' doesn't work on constants

Posted: Mon Oct 26, 2009 11:59 pm
by itistoday

Code: Select all

> (constant 'foo 3)
3
> (delete 'foo)
nil
> (set 'foo 3)

ERR: symbol is protected in function set : foo
Is this a bug or is there a reason for this?

Re: Bug? 'delete' doesn't work on constants

Posted: Tue Oct 27, 2009 11:41 am
by Lutz
Consider this:

Code: Select all

> (constant 'foo 3)
3
> (delete 'foo)
nil
> foo
3
> (set 'bar '123)
123
> (delete 'bar)
true
> (sym "bar" MAIN nil)
nil
> 
A symbol protected with 'constant' cannot be deleted, that's why the 'delete' returned 'nil' and 'foo' was still there, unblemished.

see also here: http://www.newlisp.org/downloads/newlis ... tml#delete
and: http://www.newlisp.org/downloads/newlis ... l.html#sym