unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Print representation of records and hash tables
@ 2017-12-11 10:32 Tianxiang Xiong
  2017-12-11 21:20 ` Philipp Stephani
  0 siblings, 1 reply; 8+ messages in thread
From: Tianxiang Xiong @ 2017-12-11 10:32 UTC (permalink / raw)
  To: Emacs developers

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

Emacs 26 introduces records, which have a print representation
<http://git.savannah.gnu.org/cgit/emacs.git/tree/doc/lispref/records.texi#n27>
starting with `#s`, followed by a list of contents.

This seems similar to the print representation of hash tables:

(make-hash-table)
;; => #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8
data ( ...))

Is this merely "coincidence", or is there some deeper meaning? If not,
isn't it confusing to have two different objects w/ such similar print
representations?

[-- Attachment #2: Type: text/html, Size: 659 bytes --]

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

* Re: Print representation of records and hash tables
  2017-12-11 10:32 Print representation of records and hash tables Tianxiang Xiong
@ 2017-12-11 21:20 ` Philipp Stephani
  2017-12-12 15:21   ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Philipp Stephani @ 2017-12-11 21:20 UTC (permalink / raw)
  To: Tianxiang Xiong; +Cc: Emacs developers

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

Tianxiang Xiong <tianxiang.xiong@gmail.com> schrieb am Mo., 11. Dez. 2017
um 11:32 Uhr:

> Emacs 26 introduces records, which have a print representation
> <http://git.savannah.gnu.org/cgit/emacs.git/tree/doc/lispref/records.texi#n27>
> starting with `#s`, followed by a list of contents.
>
> This seems similar to the print representation of hash tables:
>
> (make-hash-table)
> ;; => #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8
> data ( ...))
>
> Is this merely "coincidence", or is there some deeper meaning? If not,
> isn't it confusing to have two different objects w/ such similar print
> representations?
>

Yes, it's confusing, and I'm very much against it. Interpretation of ELisp
code (even compiled code) now changes in a very subtle manner depending on
whether a record named `hash-table` happens to be defined or not.

[-- Attachment #2: Type: text/html, Size: 1265 bytes --]

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

* Re: Print representation of records and hash tables
  2017-12-11 21:20 ` Philipp Stephani
@ 2017-12-12 15:21   ` Stefan Monnier
  2017-12-12 17:12     ` Ted Zlatanov
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2017-12-12 15:21 UTC (permalink / raw)
  To: emacs-devel

> Yes, it's confusing, and I'm very much against it. Interpretation of ELisp
> code (even compiled code) now changes in a very subtle manner depending on
> whether a record named `hash-table` happens to be defined or not.

Similarly, interpretation of Elisp code can change in a very subtle
manner if someone does (fset 'apply (lambda ...)).


        Stefan




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

* Re: Print representation of records and hash tables
  2017-12-12 15:21   ` Stefan Monnier
@ 2017-12-12 17:12     ` Ted Zlatanov
  2017-12-12 20:22       ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Ted Zlatanov @ 2017-12-12 17:12 UTC (permalink / raw)
  To: emacs-devel

On Tue, 12 Dec 2017 10:21:53 -0500 Stefan Monnier <monnier@iro.umontreal.ca> wrote: 

>> Yes, it's confusing, and I'm very much against it. Interpretation of ELisp
>> code (even compiled code) now changes in a very subtle manner depending on
>> whether a record named `hash-table` happens to be defined or not.

SM> Similarly, interpretation of Elisp code can change in a very subtle
SM> manner if someone does (fset 'apply (lambda ...)).

OK, but the read behavior is more broken. Right now records have
basicall taken over all #s

Ted




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

* Re: Print representation of records and hash tables
  2017-12-12 17:12     ` Ted Zlatanov
@ 2017-12-12 20:22       ` Stefan Monnier
  2017-12-14  3:33         ` Tianxiang Xiong
  2017-12-14  5:22         ` Ted Zlatanov
  0 siblings, 2 replies; 8+ messages in thread
From: Stefan Monnier @ 2017-12-12 20:22 UTC (permalink / raw)
  To: emacs-devel

>>> Yes, it's confusing, and I'm very much against it. Interpretation of ELisp
>>> code (even compiled code) now changes in a very subtle manner depending on
>>> whether a record named `hash-table` happens to be defined or not.
SM> Similarly, interpretation of Elisp code can change in a very subtle
SM> manner if someone does (fset 'apply (lambda ...)).
> OK, but the read behavior is more broken. Right now records have
> basicall taken over all #s

No, only those that are not taken by other uses.


        Stefan




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

* Re: Print representation of records and hash tables
  2017-12-12 20:22       ` Stefan Monnier
@ 2017-12-14  3:33         ` Tianxiang Xiong
  2017-12-14 14:19           ` Stefan Monnier
  2017-12-14  5:22         ` Ted Zlatanov
  1 sibling, 1 reply; 8+ messages in thread
From: Tianxiang Xiong @ 2017-12-14  3:33 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs developers

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

@Stefan, perhaps it'd be helpful to explain *why* `#s` was chosen. I'd
guess it's to fit with the `#s` read macro for structures
<https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node191.html> in CL?

It's too bad hash tables already use `#s`--`#{`
<http://frank.kank.net/essays/hash.html> or `#h` <http://cl21.org/> would
be more appropriate.


On Tue, Dec 12, 2017 at 12:22 PM, Stefan Monnier <monnier@iro.umontreal.ca>
wrote:

> >>> Yes, it's confusing, and I'm very much against it. Interpretation of
> ELisp
> >>> code (even compiled code) now changes in a very subtle manner
> depending on
> >>> whether a record named `hash-table` happens to be defined or not.
> SM> Similarly, interpretation of Elisp code can change in a very subtle
> SM> manner if someone does (fset 'apply (lambda ...)).
> > OK, but the read behavior is more broken. Right now records have
> > basicall taken over all #s
>
> No, only those that are not taken by other uses.
>
>
>         Stefan
>
>
>

[-- Attachment #2: Type: text/html, Size: 1560 bytes --]

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

* Re: Print representation of records and hash tables
  2017-12-12 20:22       ` Stefan Monnier
  2017-12-14  3:33         ` Tianxiang Xiong
@ 2017-12-14  5:22         ` Ted Zlatanov
  1 sibling, 0 replies; 8+ messages in thread
From: Ted Zlatanov @ 2017-12-14  5:22 UTC (permalink / raw)
  To: emacs-devel

On Tue, 12 Dec 2017 15:22:49 -0500 Stefan Monnier <monnier@iro.umontreal.ca> wrote: 

>> OK, but the read behavior is more broken. Right now records have
>> basicall taken over all #s

SM> No, only those that are not taken by other uses.

That's what I'm saying, yes, but without the double negative.

Ted




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

* Re: Print representation of records and hash tables
  2017-12-14  3:33         ` Tianxiang Xiong
@ 2017-12-14 14:19           ` Stefan Monnier
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2017-12-14 14:19 UTC (permalink / raw)
  To: emacs-devel

> @Stefan, perhaps it'd be helpful to explain *why* `#s` was chosen.

Why not?

It makes no sense to have a record type `hash-table` because that type
is already used for something else, so there's no ambiguity for
`#s(hash-table`

Basically, the general syntax is `#s(<type> <foo>)` where <foo> is
interpreted depending on <type>.

> I'd guess it's to fit with the `#s` read macro for structures
> <https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node191.html> in CL?

I don't think it attempts to really be compatible with this, but yes,
it was inspired by it.


        Stefan




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

end of thread, other threads:[~2017-12-14 14:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-11 10:32 Print representation of records and hash tables Tianxiang Xiong
2017-12-11 21:20 ` Philipp Stephani
2017-12-12 15:21   ` Stefan Monnier
2017-12-12 17:12     ` Ted Zlatanov
2017-12-12 20:22       ` Stefan Monnier
2017-12-14  3:33         ` Tianxiang Xiong
2017-12-14 14:19           ` Stefan Monnier
2017-12-14  5:22         ` Ted Zlatanov

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).