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

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

Re: Add-to-list or setq append...


From: Andrea Crotti
Subject: Re: Add-to-list or setq append...
Date: Wed, 04 Aug 2010 10:02:42 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.2 (darwin)

"Drew Adams" <address@hidden> writes:
>
> No, it is not.  The former unconditionally adds the entry at the beginning of
> the alist.  The latter adds the entry to the alist only if an `equal' entry is
> not already present. 
>
> The former ensures that the entry is at the start of the list.  The latter 
> does
> not.  
>
> In the former case the alist can end up with multiple entries with the given
> key, the first such entry shadowing all others with the same key.  If you then
> pop off that first entry, the previously first of all entries with that key is
> still present and now becomes the one that matters (shadows any others with 
> that
> key).

Sure but
--8<---------------cut here---------------start------------->8---
ELISP> my-l
((1 . 3)
 (1 . 2))

ELISP> (add-to-list 'my-l '(2 . 3))
((2 . 3)
 (1 . 3)
 (1 . 2))
--8<---------------cut here---------------end--------------->8---

it actually not add it ONLY if they're really equal, which is desirable
in my opinion.
What's the point in having twice the same cons in auto-mode-alist?

Then the real difference is that I add in the end instead of at the
beginning, and in that case I don't shadow an already present value...




reply via email to

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