[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GOOPS %modify-[instance|class]

From: Clinton Ebadi
Subject: Re: GOOPS %modify-[instance|class]
Date: Sun, 19 Jan 2003 23:01:17 -0500
User-agent: KMail/1.4.2

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

[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?)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]