unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Clinton Ebadi <clinton@unknownlamer.org> (by way of Clinton Ebadi <clinton@unknownlamer.org>)
Subject: Re: GOOPS %modify-[instance|class]
Date: Sun, 19 Jan 2003 23:01:17 -0500	[thread overview]
Message-ID: <200301192301.17887.clinton@unknownlamer.org> (raw)

On Wednesday 15 January 2003 07:38, Mikael Djurfeldt wrote:
> BTW, (oop goops save) seems to do something related to what you want
> to do.

In fact, it does almost everything I need. I was trying to use class
redefinition to
handle cycles in objects by storing an object in a proxy object and then (at
the end of serialization) resolving all cycles by converting all remaining
proxy objects into the objects they held. The save module does what my code
used to: have each object that contains another object recieve a copy of the
object instead of a pointer to the original object (which causes problems).

The first bug was that I was using #:init-key instead of #:init-keyword.
 After fixing that it doesn't explode but still doesn't work quite right. Is
 there anyway to use the MOP to lazily update all instances of one class to
 some unspecified second class in place? I can't see anything that would
 allow me to do handle recursive cycles in objects unless I integrated the
 serializer in the GC (and therefore written in C, something I do not want to
 do).

[ten minutes later]

This new method works:

(define-method (change-class (obj <unserializing>) (new <class>))
  (format #t "change-class: ~A:~A " obj (class-of obj))
  (let ((object (slot-ref obj 'object)))
    (%modify-instance obj (shallow-clone object))))

I changed some other stuff, but if %modify-instance is made public I can very
easily handle cycles in objects and my object serializer works (I do need to
go in and make it more efficient, but the point is that it /works/). The
project that I am writing this for is supposed to be 100% Scheme, but if I
have to I'll just include a copy of %modify-instance if I have to. The only
problem I have is that if I try to serialize an unserialized object I get
"Slot `object' is unbound in object #<<unserializing1> [address]>"  which
appears to be because the class <unserializing> is now invalid (is there a
way to make it valid again?)

--
http://unknownlamer.org


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


             reply	other threads:[~2003-01-20  4:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-20  4:01 Clinton Ebadi [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-01-09  2:51 GOOPS %modify-[instance|class] Clinton Ebadi
2003-01-10 10:12 ` Mikael Djurfeldt
2003-01-12 21:45   ` Clinton Ebadi
2003-01-15 12:38     ` Mikael Djurfeldt

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=200301192301.17887.clinton@unknownlamer.org \
    --to=clinton@unknownlamer.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).