How delete works?

Started by Kazimir Majorinc, August 01, 2008, 10:44:14 AM

Previous topic - Next topic

Kazimir Majorinc

I expected that it deletes symbol from the list of symbols, but it doesn't:


Quote> (set 'delete-me nil)

nil

> (find 'delete-me (symbols))

108

> (delete 'delete-me)

true

> (find 'delete-me (symbols))

108
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

Lutz

#1
It does delete it, but as soon as you use it it is created again, better check for the symbol using a string:


> (find "delete-me" (map string (symbols)))
108
> (delete 'delete-me)
true
> (find "delete-me" (map string (symbols)))
nil
>


You can use an extra nil flag in 'sym' to check for existence of a symbol without creating it:


> (sym "delete-me" MAIN nil)
> nil