all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Lars Brinkhoff <lars@nocrew.org>
Cc: emacs-devel@gnu.org
Subject: Re: User-defined record types
Date: Wed, 15 Mar 2017 10:38:23 -0400	[thread overview]
Message-ID: <jwvinna1upo.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <86fuif22o6.fsf@molnjunk.nocrew.org> (Lars Brinkhoff's message of "Tue, 14 Mar 2017 18:23:05 +0100")

>>> - If you don't pass the :type option to cl-defstruct, you get a
>>> cl-struct-FOO type tag in slot 0.
>> That's right.  And this symbol's value is the class object.
>> The same holds for EIEIO.
>> These are the main candidates for use of the new `record` type.
> Yes, at first I tried to make cl-deftype do this by default.  But I ran
> into problems in cl-preloaded.el and cl-generic.el.

I can help with that.

> Right, I just wanted to list all possible variations to gain some
> understanding.  For example, I don't know if it makes a difference if
> the slot 0 type tag has the form cl-struct-FOO as is the default, or
> just FOO as when you specify :type.  But now I know there might be.

The cl-struct-FOO symbol was used instead of just FOO in order to try
and avoid false-positives (i.e. to try and avoid mistakenly recognizing
some random array as being a cl-struct object).

With `record` you don't need that trick any more, so records could have
the FOO symbol in their slot 0.

For EIEIO objects, it would slow things down a bit, because EIEIO
accessors needs to consult the class object, so the time it takes to get
from (aref obj 0) to the actual class object is important: if we put the
actual type symbol, that means that we'd need something like

    (get (aref obj 0) 'cl--class)

whereas the current code uses

    (symbol-value (aref obj 0))

The problem being that the identifier used for the type name might
already be used as a variable as well as as function, so we can't use
the `symbol-value` or `symbol-function` slot.

As mentioned, ideally, we'd want to store the class object directly in
the slot 0.  The downside is that prin1 would then dump the class object
as well, so when reading dumped objects we'd end up creating another
copy of the class object rather than reusing an existing class object.
And this will break cl-generic dispatch which compares class objects
with `eq`.


        Stefan



  reply	other threads:[~2017-03-15 14:38 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-29 20:52 bug#25295: 26.0.50; Represent eieio objects using object-print in backtraces and edebug Eric Abrahamsen
     [not found] ` <handler.25295.B.148304476023950.ack@debbugs.gnu.org>
2016-12-29 21:50   ` bug#25295: Acknowledgement (26.0.50; Represent eieio objects using object-print in backtraces and edebug) Eric Abrahamsen
2016-12-30  3:42     ` npostavs
2016-12-30 19:14       ` Eric Abrahamsen
2016-12-31  5:48         ` npostavs
2016-12-31 18:56           ` Eric Abrahamsen
2016-12-31 19:23             ` npostavs
2016-12-31 20:52               ` Eric Abrahamsen
2016-12-30  7:51     ` Eli Zaretskii
2017-01-03 18:21     ` bug#25295: Represent eieio objects using object-print in backtraces and edebug Stefan Monnier
2017-01-04 23:40       ` Eric Abrahamsen
2017-01-05  1:51         ` Stefan Monnier
2017-01-05  2:11           ` Stefan Monnier
2017-01-05  4:37             ` Stefan Monnier
2017-01-05 15:39               ` Eli Zaretskii
2017-01-06  0:42                 ` Stefan Monnier
2017-01-06  7:50                   ` Eli Zaretskii
2017-02-21  2:56               ` npostavs
2017-02-21 17:23                 ` Stefan Monnier
2017-02-22 16:15                   ` Richard Stallman
2017-02-22 19:08                     ` Stefan Monnier
2017-03-02  5:36                   ` Elisp printer (was: bug#25295: Represent eieio objects using object-print in backtraces and edebug) Michael Heerdegen
2017-03-02  6:38                     ` Elisp printer Stefan Monnier
2017-03-03  2:14                       ` Michael Heerdegen
2017-03-03  2:38                         ` Stefan Monnier
2017-03-03  4:23                           ` Michael Heerdegen
2017-03-06  2:50                             ` Stefan Monnier
2017-03-08  4:09                       ` Tom Tromey
2017-03-08  4:39                         ` Stefan Monnier
2017-03-08  6:35                           ` Tom Tromey
2017-03-08  9:43                             ` Stefan Monnier
2017-03-08 18:17                         ` Lars Brinkhoff
2017-03-08 23:02                           ` Stefan Monnier
2017-03-09 15:12                             ` Lars Brinkhoff
2017-03-14  9:52                             ` User-defined record types Lars Brinkhoff
2017-03-14 12:28                               ` Lars Brinkhoff
     [not found]                             ` <86bmt42nk2.fsf_-_@molnjunk.nocrew.org>
     [not found]                               ` <jwvzigoow0k.fsf-monnier+emacs@gnu.org>
2017-03-14 13:25                                 ` Lars Brinkhoff
2017-03-14 14:28                                   ` Lars Brinkhoff
2017-03-14 15:20                                     ` Stefan Monnier
2017-03-14 17:23                                       ` Lars Brinkhoff
2017-03-15 14:38                                         ` Stefan Monnier [this message]
2017-03-15 18:14                                           ` Lars Brinkhoff
2017-03-15 19:12                                             ` Stefan Monnier
2017-03-15 19:21                                               ` Lars Brinkhoff
2017-03-15 20:05                                                 ` Stefan Monnier
2017-03-15 21:49                                               ` Lars Brinkhoff
2017-03-15 23:42                                                 ` Stefan Monnier
2017-03-16  3:05                                               ` Stefan Monnier
2017-03-16  3:08                                                 ` Stefan Monnier
2017-03-16 20:03                                                 ` Lars Brinkhoff
2017-03-16 21:32                                                   ` Stefan Monnier
2017-03-17 11:22                                                     ` Lars Brinkhoff
2017-03-17 20:45                                                     ` Lars Brinkhoff
2017-03-18 23:24                                                 ` Stefan Monnier
2017-03-18 23:36                                                   ` Stefan Monnier
2017-03-19  9:34                                                   ` Lars Brinkhoff
2017-03-19 12:42                                                     ` Stefan Monnier
2017-03-02  7:00 ` bug#25295: 26.0.50; Represent eieio objects using object-print in backtraces and edebug Stefan Monnier
2017-03-02 12:52   ` npostavs
2017-03-02 13:38     ` Stefan Monnier
2017-03-11  5:43       ` npostavs
2017-03-11 15:38         ` New pp (was: bug#25295: 26.0.50; Represent eieio objects using object-print in backtraces and edebug) Stefan Monnier
2017-03-11 16:05           ` Noam Postavsky
2017-03-11 16:40             ` New pp Stefan Monnier
2017-03-11 16:52               ` Noam Postavsky
2017-03-11 16:57                 ` Stefan Monnier
2017-03-12 13:31                   ` Noam Postavsky
2017-03-12 14:06                     ` Stefan Monnier
2017-03-12 16:13                       ` Noam Postavsky
2017-03-02 17:35   ` bug#25295: 26.0.50; Represent eieio objects using object-print in backtraces and edebug Eric Abrahamsen
2017-03-02 18:31     ` Stefan Monnier
2017-10-21 21:36   ` Eric Abrahamsen
2017-10-22  3:21     ` Stefan Monnier
2018-10-18 19:01       ` Eric Abrahamsen
  -- strict thread matches above, loose matches on Subject: below --
2013-10-10 11:22 RFC: User-defined pseudovectors Lars Brinkhoff
2013-10-10 14:00 ` Stefan Monnier
2013-10-10 16:30   ` Lars Brinkhoff
2013-10-10 20:42     ` Stefan Monnier
2013-10-11  6:00       ` Lars Brinkhoff
2013-10-11 12:22         ` Stefan Monnier
2013-10-12 16:01           ` User-defined record types Lars Brinkhoff
2013-10-12 18:58             ` Stefan Monnier
2013-10-18 13:39               ` Ted Zlatanov
2013-10-18 15:28                 ` Stefan Monnier
2013-10-18 23:24                   ` Ted Zlatanov
2013-10-19  2:09                     ` Stefan Monnier
2013-10-19  2:30                       ` Drew Adams
2013-10-19 11:48                       ` Ted Zlatanov
2013-10-19 14:37                         ` Stefan Monnier
2013-10-19 20:11                           ` Ted Zlatanov
2013-10-19 21:48                             ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvinna1upo.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=lars@nocrew.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.