On Thu, Oct 3, 2013 at 9:44 AM, Elias MÃ¥rtenson <loke...@gmail.com> wrote:

> On 3 October 2013 15:40, Willem Broekema <metaw...@gmail.com> wrote:
>
> > I guess you are modifying the value of *var*, which is not allowed if it
> is
> > a quoted list. That's why you need e.g. (list .. ..) or (copy-tree '(..
> ..))
> > instead of '(.. ..).
> >
> http://stackoverflow.com/questions/10365470/modifying-a-list-passed-as-a-parameter-gives-different-results-in-sbcl-and-clisp
>
> (SETQ *var* ...) does not change the list. It merely reassigns the
> variable.
>

The value that is assigned, that is the problem. That is probably a
modified literal list.

If there is literally this in the code: (setq *var* '(. . .))
then the compiler is free to extract that '(. . .) part and reuse it all
the time this setq form is executed. It can create one literal object and
keep it in memory, and always uses it as value. It does not need to build a
new list every time.
If you modify that special object, e.g. by setting the car of it, then
compiler may ignore that and upon the next setq set the value with modified
car.

- Willem

Reply via email to