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

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

Re: [External] : Re: Appending lists


From: Jean Louis
Subject: Re: [External] : Re: Appending lists
Date: Sun, 20 Jun 2021 22:59:10 +0300
User-agent: Mutt/2.0.7+183 (3d24855) (2021-05-28)

* Emanuel Berg via Users list for the GNU Emacs text editor 
<help-gnu-emacs@gnu.org> [2021-06-20 22:51]:
> After this discussion, I thought I'd examine my `nconc' once
> more and I then realized my use of them resembles a functional
> style, while it (nconc) is already destructively doing the
> updating, so that's not needed. E.g., this
> 
>   ;; (setq completion-ignored-extensions
>   ;;       (nconc completion-ignored-extensions '(".bcf" ".elc" ".run.xml")) )
> 
> can be changed into (should be changed, since the above makes
> no difference - ?) it can be changed into
> 
>   (nconc completion-ignored-extensions '(".bcf" ".run.xml"))

I would use it this way:

(setq completion-ignored-extensions 
      (append completion-ignored-extensions '(".bcf" ".run.xml")))

As that follows the habit and logic I am personally used to. It is
style preference. I like that previous variables stay the same:

(setq list-a '(1 2 3)) ⇒ (1 2 3)
(setq list-b '(a b c)) ⇒ (a b c)
(append list-a list-b) ⇒ (1 2 3 a b c)
list-a ⇒ (1 2 3)
list-b ⇒ (a b c)

But then I can use the previously defined variables to define a new
one:

(setq appended (append list-a list-b)) ⇒ (1 2 3 a b c)

and nothing changed in those:

list-a ⇒ (1 2 3)
list-b ⇒ (a b c)

while using function `nconc' would give me a habit that I rather find
detrimental or not pleasing:

(nconc appended list-a list-b) ⇒ (1 2 3 a b c 1 2 3 a b c . #6)
list-a ⇒ (1 2 3 a b c 1 2 3 a b c . #6)
list-b ⇒ (a b c 1 2 3 a b c 1 2 3 . #6)

Question is why do I need to change other lists if all what I want is
to set the first variable `appended' to someting new?

So if I don't need to change other variables I will not use `nconc'
and rather use function `append'


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

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