unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Andrew Gaylard <ag@computer.org>
To: guile-user@gnu.org
Subject: Re: Persisting GOOPS objects
Date: Mon, 21 Jan 2013 14:48:32 +0200	[thread overview]
Message-ID: <CALLpd2A-KCpkqJcPYtV5EniPB8igwrvPp0Eb7kVi15_pr0tDDQ@mail.gmail.com> (raw)
In-Reply-To: <87bocja9vr.fsf@pobox.com>

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

Thanks, Andy, for your reply -- with your patch, save-objects now completes.

However, it still appears not to create output with enough information
to re-create the objects.  If I do this...:

$ cat persistence-test.scm
(use-modules (oop goops))
(use-modules (oop goops describe))
(use-modules (oop goops save))

;; Apply Andy's fix to the readable? function
(set! (@@ (oop goops save) readable?)
        (lambda (x) (hashq-ref (@@ (oop goops save) readables) x)))

;; make a new class, make an instance of it, and show it
(define-class <ag-complex> (<number>) r i)
(define c (make <ag-complex>))
(slot-set! c 'r 3)
(slot-set! c 'i 4)
(describe c)

;; persist the instance
(define a '())
(set! a (acons 'c c a))
(save-objects a (current-output-port))

$ guile ./persistence-test.scm
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /home/apg/t/./persistence-test.scm
;;; compiled
/home/apg/.cache/guile/ccache/2.0-LE-4-2.0/home/apg/t/persistence-test.scm.go
#<<ag-complex> 932ace0> is an instance of class <ag-complex>
Slots are:
     r = 3
     i = 4
(define c '#<<ag-complex> 932ace0>)

... then that last line, which is the output of save-objects,  doesn't look
sufficient
(to my untrained eye, at any rate) to re-create the object in a
freshly-launched
guile in a new address space.  I'd expect it to contain the values for the
slots
as shown in the output from 'describe', as well as the class definition.

My assumptions derive from these comments in oop/goops/save.scm:

*;;; Save OBJECT ... to PORT so that when the data is read and evaluated
;;; OBJECT ... are re-created under names NAME ... .

*
What am I missing?

- Andrew


On Sun, Jan 20, 2013 at 10:15 PM, Andy Wingo <wingo@pobox.com> wrote:

> Hi,
>
> On Fri 18 Jan 2013 11:25, Andrew Gaylard <ag@computer.org> writes:
>
> > I'm trying to persist a GOOPS object.
> >
> > I've found oop/goops/save.scm, which defines save-object.
> > That looks like what I need.
>
> Cool.  I don't know of anyone that has used this code in many years, so
> be prepared for some bugs.  OTOH if it works fine, documentation is
> appreciated :)
>
> > scheme@(guile-user)> (save-objects l (current-output-port))
> > (define c 'c)
> > ERROR: In procedure hashq-get-handle:
> > ERROR: In procedure hashq-get-handle: Handle access not permitted on
> > weak table
>
> This is an implementation bug, introduced May 2011 by a change to the
> weak table interface.  See commit
> 1d9c2e6271105ee0f728127d9b544432b7cc0f4f for full details.
>
> I have fixed this in stable-2.0.  You can fix in in your copy by:
>
>   (set! (@@ (oop goops save) readable?)
>         (lambda (x) (hashq-ref (@@ (oop goops save) readables) x)))
>
> Regards,
>
> Andy
> --
> http://wingolog.org/
>

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

  reply	other threads:[~2013-01-21 12:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-18 10:25 Persisting GOOPS objects Andrew Gaylard
2013-01-20 20:15 ` Andy Wingo
2013-01-21 12:48   ` Andrew Gaylard [this message]
2013-01-22  9:47     ` Andy Wingo
2013-01-23 13:46       ` Andrew Gaylard
2013-01-23 15:55         ` Andy Wingo
2013-01-25 18:06           ` Andrew Gaylard

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/guile/

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

  git send-email \
    --in-reply-to=CALLpd2A-KCpkqJcPYtV5EniPB8igwrvPp0Eb7kVi15_pr0tDDQ@mail.gmail.com \
    --to=ag@computer.org \
    --cc=guile-user@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.
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).