Reputation: 33
I run following code of CLISP, but the result looks strange to me.
(setq a 'b)
(setq b 'c)
(setq c 'd)
(setq d 8)
(eval a)
(eval c)
(eval (eval a))
The output of last three line is:
C
8
D
How do I understand the output?
How could last two line have different output?
Please help explain this, thank you so much!
Upvotes: 3
Views: 68
Reputation: 139241
Evaluate (eval c)
c
-> symbol D
D
-> number 8Evaluate (eval (eval a))
a
-> symbol B
B
-> symbol C
C
-> symbol DSome basic evaluation rules for Lisp
(foo-function arg)
evaluates first the argument and then calls the function foo-function
with that evaluated argument(quote something)
returns something
(whatever it is) as it isUpvotes: 4