GNU bug report logs - #24875
26.0.50; In Dotted Pair Notation, the read function returns CDR if CAR is absent

Previous Next

Package: emacs;

Reported by: Chunyang Xu <mail <at> xuchunyang.me>

Date: Fri, 4 Nov 2016 15:40:03 UTC

Severity: minor

Tags: moreinfo

Found in version 26.0.50

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Chunyang Xu <mail <at> xuchunyang.me>, 24875 <at> debbugs.gnu.org
Subject: bug#24875: 26.0.50; In Dotted Pair Notation, the read function returns CDR if CAR is absent
Date: Tue, 06 Jul 2021 12:43:58 -0400
Lars Ingebrigtsen [2021-07-06 17:32:26] wrote:

> Chunyang Xu <mail <at> xuchunyang.me> writes:
>
>> For example, I eval this in the *scratch* buffer:
>>
>> (read "( . 123)")
>>      ⇒ 123
>>
>> (read "(1 . ( . (3 . nil)))")
>>      ⇒ (1 3)
>>
>> I can't find explanation about this behavior in elisp manual. Is it
>> expected?
>
> That is indeed very eccentric behaviour, so we should probably mention
> it somewhere?  (I guess we can't change it.)
>
> Anybody got an opinion here, or a way that we can describe it in the
> manual except pointing at the examples and then going ¯\_(ツ)_/¯?

It's the "natural" behavior if you start from

    (Ea . Ed)

as the notation for cons cells and extend it to

    (E1 E2 E3 .. . Ed)

such that

    (E1 {foo} . Ed) = (E1 . ({foo} . Ed))

because then you replace `{foo}` with the empty sequence and you get:

    (E1 . Ed) = (E1 . ( . Ed))

and hence

    Ed = ( . Ed)

It's not used very often, so in theory we could potentially change it,
but I haven't seen any good alternative interpretation for it, and
I don't see the benefit of signaling an error.


        Stefan





This bug report was last modified 4 years and 15 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.