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

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

Re: `append' vs. `nconc'


From: Pascal J. Bourguignon
Subject: Re: `append' vs. `nconc'
Date: Thu, 31 Dec 2015 04:45:26 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Emanuel Berg <embe8573@student.uu.se> writes:

> OK, so for example this:
>
> (setq completion-ignored-extensions
>       (append completion-ignored-extensions '(".bcf" ".run.xml")) )
>
> Is better as:
>
>     (nconc completion-ignored-extensions (list ".bcf" ".run.xml"))
>
> ?

No.  You should never use nconc only for effect (just like delete, etc).

Always re-assign the modified list:

    (setf completion-ignored-extensions
          (nconc completion-ignored-extensions (list ".bcf" ".run.xml")))

otherwise it will break when the place is bound to nil.  (nil is a symbol
and cannot be mutated into a cons cell!).

-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk


reply via email to

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