Thursday, May 14, 2009

Symbols are big - lexical variables

Ansi Common Lisp 8.5 Symbols and Variables

For a foo: 

(defun foo () '(1))
And evaluate:

A symbol used as a lexical variable is just a place holder: 

(symbol-name x) ; x is 'FOO

We can get name of 'x too: (symbol-name 'x) ; "X"

While other ops like (symbol-value 'x) and (symbol-function 'x) will yield error.

That's the difference between special variable and lexical variable: 
 * special variable will hold the symbol assigned to it
 * lexical variable will act as a place holder - only hold the name, and left the value-binding to the evaluator.


No comments: