From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andrew Gaylard Newsgroups: gmane.lisp.guile.user Subject: Re: Persisting GOOPS objects Date: Mon, 21 Jan 2013 14:48:32 +0200 Message-ID: References: <87bocja9vr.fsf@pobox.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=e89a8f22bc29f376e504d3cbe090 X-Trace: ger.gmane.org 1358772556 18509 80.91.229.3 (21 Jan 2013 12:49:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Jan 2013 12:49:16 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Jan 21 13:49:33 2013 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TxGob-00072u-Jl for guile-user@m.gmane.org; Mon, 21 Jan 2013 13:49:29 +0100 Original-Received: from localhost ([::1]:57577 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TxGoK-0007B6-Ix for guile-user@m.gmane.org; Mon, 21 Jan 2013 07:49:12 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:46482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TxGnm-0005hT-Fc for guile-user@gnu.org; Mon, 21 Jan 2013 07:48:42 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TxGni-0002RI-Uq for guile-user@gnu.org; Mon, 21 Jan 2013 07:48:38 -0500 Original-Received: from mail-la0-f41.google.com ([209.85.215.41]:56700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TxGni-0002Pf-IB for guile-user@gnu.org; Mon, 21 Jan 2013 07:48:34 -0500 Original-Received: by mail-la0-f41.google.com with SMTP id fo12so598591lab.0 for ; Mon, 21 Jan 2013 04:48:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=K0BG4mBc6UjYItNKm/qpR0ctxy4Y9g74pA6VGX+s3tk=; b=E2KXdf/JpYEfA+Yk8CezFdjgHH0iiVQK0IZ8VhgR01aTtVPz1NsMZAlmQuMsmHVGeX w8FengCmz+8EriVi+hfqjycEq1067rRYw6RykQCACbPgQzxfyomy/BBGi+KOzL49czzi mhb5WdmtdvQ1DtdjYpWoJfi4Wn9TIx3vo2b/nrCAHgcSVkiFRo8CjPvqwCwBkWpNe+CV vBLJCf05UPyanaQKb5Xdzp/8U7V9+2Utvk04RkL+23TRU13bv0+kS/FkPB+PPhL0pNQ/ QNrMnDI/epfVlifkxr348Q77ctCulJX6VFEzAvNoW+YZqE15eeFXAWQtBDpvxzIOiuBC PRpQ== X-Received: by 10.152.145.8 with SMTP id sq8mr17227995lab.21.1358772512716; Mon, 21 Jan 2013 04:48:32 -0800 (PST) Original-Received: by 10.114.75.6 with HTTP; Mon, 21 Jan 2013 04:48:32 -0800 (PST) In-Reply-To: <87bocja9vr.fsf@pobox.com> X-Google-Sender-Auth: NTNgtga9GwHWk_ACO6xrpR5c9kE X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.215.41 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:9894 Archived-At: --e89a8f22bc29f376e504d3cbe090 Content-Type: text/plain; charset=ISO-8859-1 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 () r i) (define c (make )) (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 #< 932ace0> is an instance of class Slots are: r = 3 i = 4 (define c '#< 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 wrote: > Hi, > > On Fri 18 Jan 2013 11:25, Andrew Gaylard 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/ > --e89a8f22bc29f376e504d3cbe090 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Thanks, Andy, for your reply -- with your p= atch, save-objects now completes.

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

$ cat pe= rsistence-test.scm
(use-modules (oop goops))
(use-modules (oop goops= describe))
(use-modules (oop goops save))

;; Apply Andy's fi= x to the readable? function
(set! (@@ (oop goops save) readable?)
=A0=A0=A0=A0=A0=A0=A0 (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> (&= lt;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 &= #39;())
(set! a (acons 'c c a))
(save-objects a (current-output-p= ort))

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

... then that last line, which is the output of sav= e-objects,=A0 doesn't look sufficient
(to my untrained eye, at any r= ate) to re-create the object in a freshly-launched
guile in a new addres= s space.=A0 I'd expect it to contain the values for the slots
as shown in the output from 'describe', as well as the class defini= tion.

My assumptions derive from these comments in oop/goops/save.sc= m:

;;; 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. =A0I don't know of anyone that has used this code in many y= ears, so
be prepared for some bugs. =A0OTOH 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. =A0See commit
1d9c2e6271105ee0f728127d9b544432b7cc0f4f for full details.

I have fixed this in stable-2.0. =A0You can fix in in your copy by:

=A0 (set! (@@ (oop goops save) readable?)
=A0 =A0 =A0 =A0 (lambda (x) (hashq-ref (@@ (oop goops save) readables) x)))=

Regards,

Andy
--
http://wingolog.org/=

--e89a8f22bc29f376e504d3cbe090--