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

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

Re: Appending lists


From: tomas
Subject: Re: Appending lists
Date: Wed, 16 Jun 2021 20:54:51 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

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!
>    (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

Attachment: signature.asc
Description: Digital signature


reply via email to

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