[COLUG] Re: Lisp variable scope

David Riggs dariggs at humnet.ucla.edu
Sun Dec 3 12:52:47 EST 2006


Steven said
> The behavior actually has nothing to do with lists, but rather
> with the quote operator and the particular Lisp implementation.
...

>quote is handled at read time, not evaluation time!  The
> object '("a" . 3) is a literal value in your code, and modifying
> a literal value has undefined behavior.
> 
> When you use (cons "a" 0), that is a function that is evaluated each
> time through the loop.  Each time you are guaranteed to be working
> with a fresh object with value ("a" . 0).

Thanks so much for taking the time to write such a long and clear 
explanation. I finally get it. Emacs was reusing that bit of memory 
because it was created with quote and should not have been messed with 
by my code. I was wearing out the pages of my Lisp books trying to see 
through this simple read vs evaluation time.

Yours,

David Riggs



More information about the colug432 mailing list