emacs-devel
[Top][All Lists]
Advanced

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

RE: [ELPA] New package: transient


From: Drew Adams
Subject: RE: [ELPA] New package: transient
Date: Mon, 4 May 2020 09:04:06 -0700 (PDT)

>   > What's an alist?  It's a list.  What's a (true)
>   > list?  It's a sequence.
>   > `copy-sequence' (aka `copy-seq') also copies an
>   > alist.
> 
> 'copy-sequence' is usually not an adequate way to copy an alist.
> It copies the backbone but not the associations.
> When you modify the associations -- which you presumably intend
> to do -- the two copies will both be changed.
> 
> To copy an alist properly, you need to use 'copy-alist',
> and that is why we added that function.

Oh, right; forgot.  Thx.

(setq foo '((a . A))) ; foo is ((a . A))

(setq titi (copy-alist foo)) ; titi is ((a . A))
(setcdr (car titi) 'AA)      ; titi is ((a . AA))

foo is still ((a . A))

(setq bar (copy-sequence foo)) ; bar is ((a . A))
(setcdr (car bar) 'AA)         ; bar is ((a . AA))

foo is now   ((a . AA))



reply via email to

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