Page 1 of 1

Strange function symbol?

Posted: Sun Nov 23, 2003 6:15 pm
by HPW

Code: Select all

newLISP v7.3.8 Copyright (c) 2003 Lutz Mueller. All rights reserved.

> (set (symbol "var") 345)
345
> (symbol? var)
nil
> 
Why does it return nil?

Posted: Sun Nov 23, 2003 7:31 pm
by Lutz
the function 'symbol?' evaluates its argument first, the contents of var was not a symbol but 345:

(set 'x 'var) = > var

(symbol? x) => true ;; checks the contents of x which is the symbol var

(symbol? (first '(var x y z))) => true

etc.

Lutz

Posted: Sun Nov 23, 2003 9:02 pm
by HPW
Oops, thanks for the explanation.

Posted: Sun Nov 23, 2003 10:25 pm
by HPW

Code: Select all

(set 'var any-thing)
(symbol? any-thing)     => true
The doc is not that clear.

Posted: Sun Nov 23, 2003 10:50 pm
by Lutz
the doc is wrong ;-)

I'll correct this

Lutz