From: Andy Wingo <wingo@pobox.com>
To: Andrew Gaylard <ag@computer.org>
Cc: guile-user@gnu.org
Subject: Re: Persisting GOOPS objects
Date: Wed, 23 Jan 2013 16:55:10 +0100 [thread overview]
Message-ID: <87txq7lwrl.fsf@pobox.com> (raw)
In-Reply-To: <CALLpd2AWp1bbNg1UgOvCkF9srjVYm05mQNDB_hgaHASgGuE=vQ@mail.gmail.com> (Andrew Gaylard's message of "Wed, 23 Jan 2013 15:46:41 +0200")
[-- Attachment #1: Type: text/plain, Size: 1698 bytes --]
Hi,
On Wed 23 Jan 2013 14:46, Andrew Gaylard <ag@computer.org> writes:
> I made another attempt using strings instead of numbers, to get an idea
> of whether save.scm is usable:
>
> $ 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-record> (<object>) name addr)
> (define r (make <ag-record>))
> (slot-set! r 'name "Fred")
> (slot-set! r 'addr "101 Elm Street")
> (describe r)
>
> ;; persist the instance
> (define a '())
> (set! a (acons 'r r a))
> (save-objects a (current-output-port))
>
> $ guile
> scheme@(guile-user)> (load "persistence-test.scm")
> #<<ag-record> 9f2b2a0> is an instance of class <ag-record>
> Slots are:
> name = "Fred"
> addr = "101 Elm Street"
> (define r (restore <ag-record> (name addr) oop/goops/save.scm:423:32: In
> procedure #<procedure 9f64f48 at oop/goops/save.scm:414:21 (name aname
> get set)>:
> oop/goops/save.scm:423:32: Wrong type to apply: #<syntax-transformer
> write-component>
This tells me that this module has not worked in Guile 2.0.
Write-component is a macro, and all of its uses were before its
definition.
There is no way to patch this easily; you have to edit the file. The
attached patch is applied to git.
Now:
(save-objects a (current-output-port))
=| (define r (restore <ag-record> (name addr) "Fred" "101 Elm Street"))
Regards,
Andy
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-oop-goops-save-fix-compile-time-availability-of-writ.patch --]
[-- Type: text/x-diff, Size: 2354 bytes --]
From a3df9ad9e6be7d5fbc566a10bc9ba035a2e38f31 Mon Sep 17 00:00:00 2001
From: Andy Wingo <wingo@pobox.com>
Date: Wed, 23 Jan 2013 16:53:54 +0100
Subject: [PATCH] oop goops save: fix compile-time availability of
write-component
* module/oop/goops/save.scm (write-component)
(write-component-procedure): Move definitions up so that syntax
definition is available when compiling the rest of the file.
---
module/oop/goops/save.scm | 41 +++++++++++++++++++++++------------------
1 file changed, 23 insertions(+), 18 deletions(-)
diff --git a/module/oop/goops/save.scm b/module/oop/goops/save.scm
index 05362e0..dda2aea 100644
--- a/module/oop/goops/save.scm
+++ b/module/oop/goops/save.scm
@@ -128,6 +128,29 @@
(hashq-ref readables obj))
;;;
+;;; Writer helpers
+;;;
+
+(define (write-component-procedure o file env)
+ "Return #f if circular reference"
+ (cond ((immediate? o) (write o file) #t)
+ ((readable? o) (write (readable-expression o) file) #t)
+ ((excluded? o env) (display #f file) #t)
+ (else
+ (let ((info (object-info o env)))
+ (cond ((not (binding? info)) (write-readably o file env) #t)
+ ((not (eq? (visiting info) #:defined)) #f) ;forward reference
+ (else (display (binding info) file) #t))))))
+
+;;; write-component OBJECT PATCHER FILE ENV
+;;;
+(define-macro (write-component object patcher file env)
+ `(or (write-component-procedure ,object ,file ,env)
+ (begin
+ (display #f ,file)
+ (add-patcher! ,patcher ,env))))
+
+;;;
;;; Strings
;;;
@@ -603,24 +626,6 @@
(pop-ref! env)
(set! (objects env) (cons o (objects env)))))))
-(define (write-component-procedure o file env)
- "Return #f if circular reference"
- (cond ((immediate? o) (write o file) #t)
- ((readable? o) (write (readable-expression o) file) #t)
- ((excluded? o env) (display #f file) #t)
- (else
- (let ((info (object-info o env)))
- (cond ((not (binding? info)) (write-readably o file env) #t)
- ((not (eq? (visiting info) #:defined)) #f) ;forward reference
- (else (display (binding info) file) #t))))))
-
-;;; write-component OBJECT PATCHER FILE ENV
-;;;
-(define-macro (write-component object patcher file env)
- `(or (write-component-procedure ,object ,file ,env)
- (begin
- (display #f ,file)
- (add-patcher! ,patcher ,env))))
;;;
;;; Main engine
--
1.7.10.4
[-- Attachment #3: Type: text/plain, Size: 26 bytes --]
--
http://wingolog.org/
next prev parent reply other threads:[~2013-01-23 15:55 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
2013-01-22 9:47 ` Andy Wingo
2013-01-23 13:46 ` Andrew Gaylard
2013-01-23 15:55 ` Andy Wingo [this message]
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=87txq7lwrl.fsf@pobox.com \
--to=wingo@pobox.com \
--cc=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).