all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#24875: 26.0.50; In Dotted Pair Notation, the read function returns CDR if CAR is absent
@ 2016-11-04 13:36 Chunyang Xu
  2016-11-04 16:00 ` Andreas Schwab
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Chunyang Xu @ 2016-11-04 13:36 UTC (permalink / raw)
  To: 24875


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







^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#24875: 26.0.50; In Dotted Pair Notation, the read function returns CDR if CAR is absent
  2016-11-04 13:36 bug#24875: 26.0.50; In Dotted Pair Notation, the read function returns CDR if CAR is absent Chunyang Xu
@ 2016-11-04 16:00 ` Andreas Schwab
  2016-11-04 16:00 ` Drew Adams
  2021-07-06 15:32 ` Lars Ingebrigtsen
  2 siblings, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2016-11-04 16:00 UTC (permalink / raw)
  To: Chunyang Xu; +Cc: 24875

On Nov 04 2016, Chunyang Xu <mail@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@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#24875: 26.0.50; In Dotted Pair Notation, the read function returns CDR if CAR is absent
  2016-11-04 13:36 bug#24875: 26.0.50; In Dotted Pair Notation, the read function returns CDR if CAR is absent Chunyang Xu
  2016-11-04 16:00 ` Andreas Schwab
@ 2016-11-04 16:00 ` Drew Adams
  2021-07-06 15:32 ` Lars Ingebrigtsen
  2 siblings, 0 replies; 7+ messages in thread
From: Drew Adams @ 2016-11-04 16:00 UTC (permalink / raw)
  To: Chunyang Xu, 24875

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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#24875: 26.0.50; In Dotted Pair Notation, the read function returns CDR if CAR is absent
@ 2021-05-18 15:04 Drew Adams
  0 siblings, 0 replies; 7+ messages in thread
From: Drew Adams @ 2021-05-18 15:04 UTC (permalink / raw)
  To: 'Drew Adams', Chunyang Xu, 24875@debbugs.gnu.org

[-- Attachment #1: Type: text/plain, Size: 306 bytes --]

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

[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 12704 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#24875: 26.0.50; In Dotted Pair Notation, the read function returns CDR if CAR is absent
  2016-11-04 13:36 bug#24875: 26.0.50; In Dotted Pair Notation, the read function returns CDR if CAR is absent Chunyang Xu
  2016-11-04 16:00 ` Andreas Schwab
  2016-11-04 16:00 ` Drew Adams
@ 2021-07-06 15:32 ` Lars Ingebrigtsen
  2021-07-06 16:43   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2021-07-06 15:32 UTC (permalink / raw)
  To: Chunyang Xu; +Cc: 24875, Stefan Monnier

Chunyang Xu <mail@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





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#24875: 26.0.50; In Dotted Pair Notation, the read function returns CDR if CAR is absent
  2021-07-06 15:32 ` Lars Ingebrigtsen
@ 2021-07-06 16:43   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-07-06 17:15     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-07-06 16:43 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Chunyang Xu, 24875

Lars Ingebrigtsen [2021-07-06 17:32:26] wrote:

> Chunyang Xu <mail@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






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#24875: 26.0.50; In Dotted Pair Notation, the read function returns CDR if CAR is absent
  2021-07-06 16:43   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-07-06 17:15     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2021-07-06 17:15 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Chunyang Xu, 24875

Stefan Monnier <monnier@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





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-07-06 17:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-04 13:36 bug#24875: 26.0.50; In Dotted Pair Notation, the read function returns CDR if CAR is absent Chunyang Xu
2016-11-04 16:00 ` Andreas Schwab
2016-11-04 16:00 ` Drew Adams
2021-07-06 15:32 ` Lars Ingebrigtsen
2021-07-06 16:43   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-07-06 17:15     ` Lars Ingebrigtsen
  -- strict thread matches above, loose matches on Subject: below --
2021-05-18 15:04 Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.