Bug? 'delete' doesn't work on constants

Q&A's, tips, howto's
Locked
itistoday
Posts: 429
Joined: Sun Dec 02, 2007 5:10 pm
Contact:

Bug? 'delete' doesn't work on constants

Post 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?
Get your Objective newLISP groove on.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

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

Post 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

Locked