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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 24875 in the body.
You can then email your comments to 24875 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#24875; Package emacs. (Fri, 04 Nov 2016 15:40:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Chunyang Xu <mail <at> xuchunyang.me>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 04 Nov 2016 15:40:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Chunyang Xu <mail <at> xuchunyang.me>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.0.50;
 In Dotted Pair Notation, the read function returns CDR if CAR is
 absent
Date: Fri, 04 Nov 2016 21:36:38 +0800
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?

According to an answer [1] by wasamasa on Emacs StackExchange,
Guile behaves the same, but other Lisp interpreters (csi, pil and sbcl)
and MIT-Scheme don't permit reading this.


[1] http://emacs.stackexchange.com/a/28410/3889






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24875; Package emacs. (Fri, 04 Nov 2016 16:01:03 GMT) Full text and rfc822 format available.

Message #8 received at 24875 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Chunyang Xu <mail <at> xuchunyang.me>
Cc: 24875 <at> debbugs.gnu.org
Subject: Re: bug#24875: 26.0.50;
 In Dotted Pair Notation, the read function returns CDR if CAR is
 absent
Date: Fri, 04 Nov 2016 17:00:27 +0100
On Nov 04 2016, Chunyang Xu <mail <at> xuchunyang.me> wrote:

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

The Emacs Lisp reader has always worked that way.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24875; Package emacs. (Fri, 04 Nov 2016 16:01:03 GMT) Full text and rfc822 format available.

Message #11 received at 24875 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Chunyang Xu <mail <at> xuchunyang.me>, 24875 <at> debbugs.gnu.org
Subject: RE: bug#24875: 26.0.50; In Dotted Pair Notation, the read function
 returns CDR if CAR is absent
Date: Fri, 4 Nov 2016 09:00:52 -0700 (PDT)
Indeed.  This is not "normal" (usual) Lisp behavior.
It seems quite bizarre - unexpected, to say the least.

If this is intentional for Emacs Lisp then the Emacs-Lisp
doc should both (1) describe this behavior and (2) give the
rationale behind it.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24875; Package emacs. (Tue, 18 May 2021 15:05:02 GMT) Full text and rfc822 format available.

Message #14 received at 24875 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: 'Drew Adams'
 <IMCEAORCL-drew+2Eadams+40oracle+2Ecom <at> namprd10.prod.outlook.com>, Chunyang
 Xu <mail <at> xuchunyang.me>, "24875 <at> debbugs.gnu.org" <24875 <at> debbugs.gnu.org>
Subject: RE: bug#24875: 26.0.50; In Dotted Pair Notation, the read function
 returns CDR if CAR is absent
Date: Tue, 18 May 2021 15:04:03 +0000
[Message part 1 (text/plain, inline)]
> Indeed.  This is not "normal" (usual) Lisp behavior.
> It seems quite bizarre - unexpected, to say the least.
> 
> If this is intentional for Emacs Lisp then the Emacs-Lisp
> doc should both (1) describe this behavior and (2) give the
> rationale behind it.

ping.  Can this please be addressed?
[winmail.dat (application/ms-tnef, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24875; Package emacs. (Tue, 06 Jul 2021 15:33:02 GMT) Full text and rfc822 format available.

Message #17 received at 24875 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Chunyang Xu <mail <at> xuchunyang.me>
Cc: 24875 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#24875: 26.0.50; In Dotted Pair Notation, the read function
 returns CDR if CAR is absent
Date: Tue, 06 Jul 2021 17:32:26 +0200
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 ¯\_(ツ)_/¯?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 06 Jul 2021 15:33:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24875; Package emacs. (Tue, 06 Jul 2021 16:45:01 GMT) Full text and rfc822 format available.

Message #22 received at 24875 <at> debbugs.gnu.org (full text, mbox):

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: Re: 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





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24875; Package emacs. (Tue, 06 Jul 2021 17:16:01 GMT) Full text and rfc822 format available.

Message #25 received at 24875 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Chunyang Xu <mail <at> xuchunyang.me>, 24875 <at> debbugs.gnu.org
Subject: Re: bug#24875: 26.0.50; In Dotted Pair Notation, the read function
 returns CDR if CAR is absent
Date: Tue, 06 Jul 2021 19:15:09 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

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

Ah, I see!  Thanks for the explanation -- I now taken a stab at finding
a place in the Lisp manual to explain this (and explaining it slightly
shorter).  Feel free to adjust as required.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 28.1, send any further explanations to 24875 <at> debbugs.gnu.org and Chunyang Xu <mail <at> xuchunyang.me> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 06 Jul 2021 17:16:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 04 Aug 2021 11:24:08 GMT) Full text and rfc822 format available.

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

Previous Next


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