From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Lars Brinkhoff Newsgroups: gmane.emacs.devel Subject: Re: User-defined record types Date: Wed, 15 Mar 2017 19:14:18 +0100 Organization: nocrew Message-ID: <86a88mz9tx.fsf@molnjunk.nocrew.org> References: <87pokampa4.fsf@ericabrahamsen.net> <8760m2mmlq.fsf@ericabrahamsen.net> <87lguq5r87.fsf@ericabrahamsen.net> <878tp0i74g.fsf@users.sourceforge.net> <87efyg6y0i.fsf_-_@drachen> <87zigwz9wx.fsf@tromey.com> <86bmtbd45s.fsf@molnjunk.nocrew.org> <86bmt42nk2.fsf_-_@molnjunk.nocrew.org> <86o9x40z35.fsf@molnjunk.nocrew.org> <86k27s0w6m.fsf@molnjunk.nocrew.org> <86fuif22o6.fsf@molnjunk.nocrew.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1489601814 23170 195.159.176.226 (15 Mar 2017 18:16:54 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 15 Mar 2017 18:16:54 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 15 19:16:49 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1coDTX-0005Dg-C3 for ged-emacs-devel@m.gmane.org; Wed, 15 Mar 2017 19:16:43 +0100 Original-Received: from localhost ([::1]:38919 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1coDTd-0003ZB-Dm for ged-emacs-devel@m.gmane.org; Wed, 15 Mar 2017 14:16:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56817) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1coDRR-0002DJ-QQ for emacs-devel@gnu.org; Wed, 15 Mar 2017 14:14:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1coDRO-00068d-K5 for emacs-devel@gnu.org; Wed, 15 Mar 2017 14:14:33 -0400 Original-Received: from [195.159.176.226] (port=47509 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1coDRO-000670-CG for emacs-devel@gnu.org; Wed, 15 Mar 2017 14:14:30 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1coDRG-00010J-6e for emacs-devel@gnu.org; Wed, 15 Mar 2017 19:14:22 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 33 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:e3bOoQTPcG4UFU21DpHwW9/+lIc= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:213046 Archived-At: Stefan Monnier wrote: >> 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. Thanks. I got past that and made it through to a dumped emacs which uses record types for defstruct by default. However, there is still EIEIO which may well need some expert guidance to update. > 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`. Understood. I'll look into storing the class object in slot 0. I imagine there will be some circular bootstrapping problem, e.g. creating the first record object requires a class object which is a record object. Some suggestions: - type-of looks into the class object and returns the symbol naming the class. - class-of could be introduced to return a class object, like CLOS. - The read/print syntax for records uses the symbol for the type slot. Reading a record would then maybe only work right if the class object has been defined first. Not sure if that's ok.