louis's Blog

louis's Avatar Image
Software developer #Go #CommonLisp #JS #SQL. #LispWorks user. Soft spots for #Emacs #SmallWeb. Recently becoming #OpenBSD enthusiast.

Other hobbies: #Running #FireFighter #StarTrek
← All posts

I’ve underestimated how good an introduction to Common Lisp the book “ANSI Common Lisp”[1] from Paul Graham is.

This was an eye-opener:

8.7 Symbols and Variables

“One potentially confusing thing about Lisp is that symbols are related to variables in two very different ways. When a symbol is the name of a special variable, the value of the variable is stored in a field within the symbol […]. The symbol-value function refers to that field, so we have a direct connection between a symbol and the value of the special variable it represents.

With lexical variables, things are completely different. A symbol used as a lexical variable is just a placeholder. The compiler will translate it into a reference to a register or a location in memory. In the eventual compiled code, there will be no trace of the symbol (unless it is retained somewhere for use by the debugger). So of course there is no connection between symbols and the values of the lexical variables they represent; by the time there is a value, the symbol is gone.”

#CommonLisp

[1] PDF Download: https://github.com/61–/weiyanmin/blob/master/BOOK/Lisp/Graham%2C%20Paul%20-%20ANSI%20Common%20Lisp.pdf

To like or reply, open original post on Emacs.ch