unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: Eric Ludlam <ericludlam@gmail.com>
Cc: "Pierre Téchoueyres" <pierre.techoueyres@free.fr>,
	29220@debbugs.gnu.org, "Eric M. Ludlam" <zappo@gnu.org>,
	"Stefan Monnier" <monnier@IRO.UMontreal.CA>,
	"Noam Postavsky" <npostavs@users.sourceforge.net>
Subject: bug#29220: 26.0.90; eieio-persistent-read fail to restore saved object.
Date: Thu, 28 Dec 2017 10:44:45 -0800	[thread overview]
Message-ID: <87wp16y9nm.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <87y3nga0lv.fsf@killashandra.ballybran.fr>


On 12/23/17 21:18 PM, Eric Ludlam wrote:
> On 12/20/2017 09:21 PM, Eric Abrahamsen wrote:
>> On 12/20/17 15:54 PM, Stefan Monnier wrote:
>>>> As for the quoting thing, my current idea is to not add quotes to lists
>>>> when writing, then strip quotes on restore, if the car of the list is a
>>>> valid class symbol then try to restore an object, but wrap in
>>>> `condition-case' and return the plain list if an error is raised.
>>> I recommend you ask the opinion of Eric M. Ludlam <zappo@gnu.org>
>>> (the original author of that code).
>> Okay!
>>
>> Eric, I'm dragging you into this because we're having a little trouble
>> with the eieio persistence functionality. Sorry...
>>
>> In Emacs 26 objects are implemented using records, which (long story
>> short) means that their representations from `prin1' are no longer
>> reconstructable using `read', which is causing problems for
>> eieio-persistent.
> Hey, thanks for checking in.
>
> I know a bunch of eieio was re-written to be faster and better, but I
> haven't been keeping up with the latest version.  For mysterious
> reasons, Ubuntu is still on Emacs 24 so I'm still on the old stuff.
>> The current persistence read/write process basically only handles
>> top-level slot values. It looks at the value, does one of the following:
>>
>> 1. Writes an object using `object-write'
>> 2. Writes a list of objects using a "list" plus `object-write'
>> 3. Quotes a list and prints it
>> 4. Prints value directly
>>
>> If objects are inside lists, hash tables, or vectors (or anything else),
>> they are not written using `object-write'. This used to not be a problem
>> because their `prin1' representation was still readable.
>>
>> This is no longer the case, which leads to failure for libraries that
>> put objects inside other data structures.
>
> The original purpose of object-write on eieio objects was to prevent
> circular references which kept popping up in EDE and SemanticDB. The first
> version just dumped the old raw vector.  That's one of the reasons why it
> doesn't try to be pedantic about carefully going down through every list.
> It only had to deal with EDE and Semantic classes.

Thanks for the response! It's good to have a bit of background.

Would you mind pointing me in the direction of some tests or other code
that I can use to make sure the temporary fix works for CEDET and
family? It seems likely that what will happen for Emacs 26 is that I'll
do a limited set of fixes to ensure that no major packages break, and
then try to come up with a more comprehensive solution for Emacs 27.
Right now I've got tests aimed at pcache and the Gnus registry, but I'd
like to make sure EDE and Semantic work correctly, as well.

>> My feeling is that both the write and restore process should walk the
>> entire tree of whatever object is being written. The write process
>> should turn objects into list representations, nothing more. The restore
>> process should restore objects, and strip strings of properties (I've
>> got the outline of this in bug#29541), and nothing more. If the restore
>> process was destructive, it would save some consing.
> I think that makes sense.  I was definitely taking short-cuts in letting
> lists write themselves b/c I was lazy.  Based on what you describe, it
> probably makes sense to walk entire structures and write each step.
>
> It might be even better if that was a core Emacs feature, and not something
> specific to a simple eieio utility base class.  :)

Coincidentally, John Wiegley posted a possible generic structure-walking
function (called "traverse") to this list not too long ago.

[...]

> For example, you might say that any list that starts with a class
> symbol is an
> object and everything else is data.  Of course, then you can't have a
> list of
> class symbols, and definitely need to avoid having classes with simple
> names.

[...]

> Don't forget that objects can execute code in their 'object-write' to
> convert
> an inconvenient data structure into something simple, and in the constructor
> convert it back again.
>
> For example, have a slot with the hash table be non-savable (no :initarg).
> In the object-write, convert the hash table into a simple flat list on
> a different slot with an :initarg.
>
> On load, copy the content of the :initarg slot back into your hash table.
>
> In this way, you may be able to have the 2 examples avoid having any
> problems
> with the current system in E26.
>
> Not that I don't know what the real issues are.  I'm just tossing some
> options out
> there.

Okay, thanks very much for these responses. I've got some ideas about
the full fix, and will work on those in a separate bug report.

Thanks again,
Eric





  reply	other threads:[~2017-12-28 18:44 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-08 22:04 bug#29220: 26.0.90; eieio-persistent-read fail to restore saved object Pierre Téchoueyres
2017-11-08 22:48 ` Eric Abrahamsen
2017-11-10 17:31   ` Pierre Téchoueyres
2017-11-10 18:12     ` Eric Abrahamsen
2017-11-10 18:32       ` Pierre Téchoueyres
2017-11-12 19:10       ` Noam Postavsky
2017-11-14 22:30         ` Pierre Téchoueyres
2017-11-15  2:02           ` Noam Postavsky
2017-11-15 15:29             ` Stefan Monnier
2017-11-17 19:56               ` Pierre Téchoueyres
2017-11-18  3:40             ` Noam Postavsky
2017-11-18  4:39               ` Eric Abrahamsen
2017-11-18 13:24                 ` Noam Postavsky
2017-11-18 18:14                   ` Eric Abrahamsen
2017-11-19  3:17                     ` Noam Postavsky
2017-11-19  5:57                       ` Eric Abrahamsen
2017-11-23 23:20                       ` Pierre Téchoueyres
2017-11-24  0:09                         ` Noam Postavsky
2017-11-28 21:39                           ` Pierre Téchoueyres
2017-11-28 21:52                             ` Noam Postavsky
2017-11-28 22:18                               ` Pierre Téchoueyres
2017-11-29  1:09                                 ` Noam Postavsky
2017-11-29 15:18                                   ` Stefan Monnier
2017-11-28 22:10                             ` Eric Abrahamsen
2017-11-29 15:15                               ` Stefan Monnier
2017-12-01 17:25                                 ` Eric Abrahamsen
2017-12-01 17:55                                   ` Stefan Monnier
2017-12-03  0:17                                     ` Eric Abrahamsen
2017-12-03 18:35                                       ` Pierre Téchoueyres
2017-12-05  1:27                                         ` Eric Abrahamsen
2017-12-05  2:08                                           ` Stefan Monnier
2017-12-05 17:47                                             ` Eric Abrahamsen
2017-12-05 19:02                                               ` Stefan Monnier
2017-12-05 20:56                                                 ` Eric Abrahamsen
2017-12-05 22:14                                                   ` Stefan Monnier
2017-12-05 22:58                                                     ` Eric Abrahamsen
2017-12-08 10:41                                                       ` Eli Zaretskii
2017-12-09 16:59                                                         ` Eric Abrahamsen
2017-12-12 23:21                                                           ` Noam Postavsky
2017-12-15 20:26                                                             ` Pierre Téchoueyres
2017-12-15 22:26                                                               ` Pierre Téchoueyres
2017-12-16 23:42                                                                 ` Eric Abrahamsen
2018-02-20 19:50                                                                   ` Pierre Téchoueyres
2018-02-24 21:23                                                                     ` Eric Abrahamsen
2018-02-24 23:21                                                                       ` Pierre Téchoueyres
2018-02-24 23:40                                                                         ` Eric Abrahamsen
2018-02-25  0:34                                                                           ` Pierre Téchoueyres
2018-02-25 18:59                                                                             ` Eric Abrahamsen
2019-05-27 23:36                                                                               ` Noam Postavsky
2019-05-28 21:17                                                                                 ` Eric Abrahamsen
2019-05-30 22:50                                                                                 ` Noam Postavsky
2017-12-18 19:52                                                                 ` Eric Abrahamsen
2017-12-18 21:38                                                                   ` Stefan Monnier
2017-12-20 18:29                                                                     ` Eric Abrahamsen
2017-12-20 20:54                                                                       ` Stefan Monnier
2017-12-21  2:21                                                                         ` Eric Abrahamsen
2017-12-24  2:18                                                                           ` Eric Ludlam
2017-12-28 18:44                                                                             ` Eric Abrahamsen [this message]
2017-12-05 22:20                                                   ` Pierre Téchoueyres
2018-01-24 19:17                                                     ` Pierre Téchoueyres
2018-01-25  3:09                                                       ` Eric Abrahamsen

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87wp16y9nm.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=29220@debbugs.gnu.org \
    --cc=ericludlam@gmail.com \
    --cc=monnier@IRO.UMontreal.CA \
    --cc=npostavs@users.sourceforge.net \
    --cc=pierre.techoueyres@free.fr \
    --cc=zappo@gnu.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 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).