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

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

Re: Adding many elements to a list


From: David Kastrup
Subject: Re: Adding many elements to a list
Date: Tue, 22 Sep 2009 14:16:28 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

pjb@informatimago.com (Pascal J. Bourguignon) writes:

> David Kastrup <dak@gnu.org> writes:
>
>> pjb@anevia.com (Pascal J. Bourguignon) writes:
>>
>>> David Kastrup <dak@gnu.org> writes:
>>>
>>>> pjb@anevia.com (Pascal J. Bourguignon) writes:
>>>>
>>>>> David Kastrup <dak@gnu.org> writes:
>>>>>
>>>>>> pjb@informatimago.com (Pascal J. Bourguignon) writes:
>>>>>>
>>>>>>> So better use (require 'cl) (push new-item list)
>>>>>>>    or (cons new-item list)
>>>>>>>    or (append (list new-items...) list)
>>>>>>
>>>>>> (require 'cl) is quite unnecessary for all of the mentioned
>>>>>> alternatives.
>>
>> Try emacs -Q.  Just because you choose to load some library
>> overloading the default operators does not mean that other people
>> should do the same when Emacs will provide those operators by
>> default, with better performance.
>
> Ah! :-)  
>
> The cl package wouldn't be provided if the default had any performance
> at all...
>
>
> (defvar *a* (cons nil nil))
> (push 1 (car *a*))

Well, consult its doc string for what it does and doesn't.  It's
basically the same issue as with setf/setq: the cl version of push does
a number of different things depending on a vague concept "location".
But you almost never need this sort of flexibility at runtime, and at
compile time, it obfuscates what actually happens, including the
possible performance impacts.

-- 
David Kastrup


reply via email to

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