[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 22:28:39 +0900 |
> On Dec 2, 2018, at 22:08, Stephen Berman <stephen.berman@gmx.net> wrote:
>>
>> 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.
>
> I don't think setq is behaving any different with lists than with other
> Lisp objects. Lists are defined this way in Lisp, cf. (info "(elisp)
> Cons Cell Type"):
Yes, but a list does not generally evaluate to a pointer to the first cell of
its cons. Which is the case when setq is used. Which is the reason why the
Introduction insists on that aspect of setq, because before that, all the setq
examples assigned "straight" values to variables.
For ex. The first sentences of "Global Variables" in the Reference are like
this:
> You specify a value for a symbol with setq. For example, (setq x '(a b))
> gives the variable x the value (a b).
They don't say:
(setq x '(a b)) stores the address of the first (cons) cell in the variable.
Which it does, and which is confusing if you expect x to hold '(a b), like I
was today.
So I think it would be nice to add a few lines here and there to clarify that
behavior.
Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune
- Re: using setq to create lists based on other lists..., (continued)
- Re: using setq to create lists based on other lists..., Jean-Christophe Helary, 2018/12/02
- Re: using setq to create lists based on other lists..., Stefan Monnier, 2018/12/02
- Re: using setq to create lists based on other lists..., Jean-Christophe Helary, 2018/12/02
- Re: using setq to create lists based on other lists..., Robert Thorpe, 2018/12/02
- Re: using setq to create lists based on other lists..., Jean-Christophe Helary, 2018/12/02
- Message not available
- Re: using setq to create lists based on other lists..., Rusi, 2018/12/03
Re: using setq to create lists based on other lists..., Barry Margolin, 2018/12/02
- Re: using setq to create lists based on other lists..., Stephen Berman, 2018/12/02
- Re: using setq to create lists based on other lists..., Jean-Christophe Helary, 2018/12/02
- Re: using setq to create lists based on other lists..., Stephen Berman, 2018/12/02
- Re: using setq to create lists based on other lists...,
Jean-Christophe Helary <=
- Re: using setq to create lists based on other lists..., Michael Heerdegen, 2018/12/02
- Re: using setq to create lists based on other lists..., Jean-Christophe Helary, 2018/12/02
- Re: using setq to create lists based on other lists..., Michael Heerdegen, 2018/12/02
- Re: using setq to create lists based on other lists..., Jean-Christophe Helary, 2018/12/02
Re: using setq to create lists based on other lists..., Stephen Berman, 2018/12/02
Re: using setq to create lists based on other lists..., Jean-Christophe Helary, 2018/12/02
Message not availableRe: using setq to create lists based on other lists..., Barry Margolin, 2018/12/04
Re: using setq to create lists based on other lists..., Jean-Christophe Helary, 2018/12/02
Re: using setq to create lists based on other lists..., Barry Margolin, 2018/12/04