Strange function symbol?

Q&A's, tips, howto's
Post Reply
HPW
Posts: 1377
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Strange function symbol?

Post 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?
Hans-Peter

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

Post 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

HPW
Posts: 1377
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

Oops, thanks for the explanation.
Hans-Peter

HPW
Posts: 1377
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

Code: Select all

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

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

Post by Lutz »

the doc is wrong ;-)

I'll correct this

Lutz

Post Reply