[Top][All Lists]

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

Re: [External] : Re: Setting up abbrev

From: Emanuel Berg
Subject: Re: [External] : Re: Setting up abbrev
Date: Mon, 01 Aug 2022 20:36:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Drew Adams wrote:

>> Okay, but I still don't understand the benefit of using it
>> in practice compared to the list (a b)?
> Do you mean use the _notation_? I guess you instead mean use
> a dotted list: a list whose last cdr is a non-nil atom.
> If so, the answer is that in general you do want to use
> a true/proper list (last cdr is nil), and NOT a dotted list.
> For many reasons, not least of which is using a function
> that needs to traverse all list elements (e.g. `length',
> mapping/sequence functions).
> You can use a dotted list in these cases:
> 1. You want to save conses (not create so many), in
>    a context where you're not going to be needing to use the
>    cons as a list (mapping etc.), or a context where you
>    know you'll only ever want an atom cdr.
> 2. You want/need, in effect, to have a backwards key-value
>    pair, (list-value . atom-key). You have a list to use for
>    most purposes (ignoring the last cdr), and you have an
>    atom (the cdr) for a few rare purposes, as a kind of
>    label for the list.
> #2 is usually the result of trying to adapt to legacy code
> that expects to treat just a list (and doesn't need to
> follow it to its end). IOW, #2 is typically an ugly hack.
> For new code you'd instead just put the atom first:
> (atom-key . list-value).

Why? What data can (a . b) hold that (list a b) cannot?

underground experts united

reply via email to

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