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

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

Re: Appending lists


From: Philip Kaludercic
Subject: Re: Appending lists
Date: Wed, 16 Jun 2021 21:24:19 +0000

<tomas@tuxteam.de> writes:

> On Wed, Jun 16, 2021 at 08:36:00PM +0300, Jean Louis wrote:
>> * Philip Kaludercic <philipk@posteo.net> [2021-06-16 16:07]:
>> > > (setq list '(A B C)) ⇒ (A B C)
>> > > (nconc list '(1 2 3)) ⇒ (A B C 1 2 3)
>> > > list  ⇒ (A B C 1 2 3)
>> > 
>> > Change that to
>> > 
>> (let* ((list-1 '(a b c))
>>         (list-2 (nconc list-1 '(1 2 3))))
>                    ^^^^ not recommended: '(a b c) is a "constant object"
>                         Some version of elisp might even refuse to do that!

True, I wanted to do (list 'a 'b 'c) but I didn't want to change the
example that much.

Also, what versions of elisp wouldn't allow that?

>>    (eq list-1 list-2)) ;; => t
>> 
>> eq - Return t if the two args are the same Lisp object.
>> 
>> And we talked how variable's value does not change... values or Lisp
>> objects?
>> 
>> (setq list-1 '(a b c))
>> list-1 ⇒ (a b c)
>> (setq list-2 (nconc list-1 '(1 2 3))) ⇒ (a b c 1 2 3)
>> list-2 ⇒ (a b c 1 2 3)
>> (eq list-1 list-2) ⇒ t
>> list-1 ⇒ (a b c 1 2 3)
>> 
>> How I see that is that it is same lisp object, but I can visually see
>> that the value changed. 
>> 
>> Maybe Thomas wanted to say that lisp object does not change? 
>
> On the contrary. Mutable objects can change. Cons cells are
> mutable objects, and thus lists, which are made of those.
>
> Cheers
>  - t
>

-- 
        Philip K.



reply via email to

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