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

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

Re: Appending to a list


From: Joost Kremers
Subject: Re: Appending to a list
Date: Sun, 13 Dec 2020 23:37:53 +0100
User-agent: mu4e 1.5.7; emacs 27.1.50

On Sun, Dec 13 2020, Óscar Fuentes wrote:
> Joost Kremers <joostkremers@fastmail.fm> writes:
>> On Sun, Dec 13 2020, steve-humphreys@gmx.com wrote:
>>> Or does one customarily use other constructs for
>>> adding to a list?
>>
>> `push` is what I would use:
>>
>>     (push "Swift" bird)
>
> This does not append.

Not in the Elisp sense, no. But in e.g., Python, `append` is the function that's
used to add an element to a list and the OP indicated that that's what he was
after.

>>     (require 'cl-lib)
>>     (cl-pushnew "Swift" bird)
>
> Isn't that the same as
>
> (add-to-list bird "Swift" t)

The doc string of `add-to-list` says that it should really only be used on
configuration variables in one's init file. For some reason (that I admittedly 
do
not understand), `add-to-list` shouldn't be used on lexical variables.

-- 
Joost Kremers
Life has its moments



reply via email to

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