[Top][All Lists]

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

RE: [External] : Re: Setting up abbrev

From: Drew Adams
Subject: RE: [External] : Re: Setting up abbrev
Date: Mon, 1 Aug 2022 19:20:20 +0000

> > 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?

Please reread what I wrote.  I never said that
(a . b) can hold data that (a b) cannot.  Nothing
like that.

I said:

1. (a . b) uses one less cons than (a b).

2. If you need to support legacy code that expects
to use a list (a b c), but you also want to label
such a list with an atom, you can sometimes use
(a b c . d) to get away with doing both.

That's all.  If the performance (space or access
time) of (a b) isn't a problem for your app, then
#1 probably doesn't apply.  If you don't need to
cover legacy cases such as #2 describes, then #2
probably doesn't apply.

Those are two use cases that come to (my) mind.

reply via email to

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