help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using setq to create lists based on other lists...


From: Jean-Christophe Helary
Subject: Re: using setq to create lists based on other lists...
Date: Sun, 2 Dec 2018 21:22:54 +0900

Stephen, thank you for the additional explanations.

> On Dec 2, 2018, at 20:51, Stephen Berman <stephen.berman@gmx.net> wrote:

>>> I don't suppose that's a bug, but really it ought the be very clearly 
>>> documented in the reference. Also, I'd like to know why that's happening.
> 
> To expand of this, since Jean-Christophe didn't find an explanation of
> this behavior of setq in the Lisp reference, but it is in fact
> documented:

Well, yes and no.

>    Special Form: setq [symbol form]...
>     This special form is the most common method of changing a
>     variable’s value.  Each SYMBOL is given a new value, which is the
>     result of evaluating the corresponding FORM.  The current binding
>     of the symbol is changed.
> 
> In the above case, the symbol `list1' is given the result of evaluating
> `list0', which is the list `'(1 2)'.  So now both `list0' and `list1'
> refer to this list,

That's not clear at all from the paragraph you quote. Because for all practical 
purposes, when I evaluate list0 I get (1 2) and not "a pointer to an object 
that is the list (1 2)".

In fact, I just found the explanation, it is in the Introduction to Emacs Lisp 
and it says:

> When a variable is set to a list with a function such as setq, it stores the 
> address of the first box in the variable.

So, setq has a specific behavior when it applies to lists: it evaluates the 
form as a pointer to an object and not as a value.

Or am I misunderstanding something ?


Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune





reply via email to

[Prev in Thread] Current Thread [Next in Thread]