From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Mikael Djurfeldt Newsgroups: gmane.lisp.guile.user Subject: Re: GOOPS %modify-[instance|class] Date: Wed, 15 Jan 2003 13:38:45 +0100 Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Message-ID: References: <200301082151.59431.clinton@unknownlamer.org> <200301121645.09362.clinton@unknownlamer.org> Reply-To: djurfeldt@nada.kth.se NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1042634506 10963 80.91.224.249 (15 Jan 2003 12:41:46 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 15 Jan 2003 12:41:46 +0000 (UTC) Cc: djurfeldt@nada.kth.se Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18YmrX-0002qZ-00 for ; Wed, 15 Jan 2003 13:41:43 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18YmqG-0002j2-01 for guile-user@m.gmane.org; Wed, 15 Jan 2003 07:40:24 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18YmpM-0002hs-00 for guile-user@gnu.org; Wed, 15 Jan 2003 07:39:28 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18YmpK-0002hd-00 for guile-user@gnu.org; Wed, 15 Jan 2003 07:39:27 -0500 Original-Received: from kvast.blakulla.net ([213.212.20.77]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18Ymop-0002Cs-00 for guile-user@gnu.org; Wed, 15 Jan 2003 07:38:56 -0500 Original-Received: from barbara.blakulla.net ([213.212.21.238] helo=linnaeus) by kvast.blakulla.net with esmtp (Exim 3.36 #1 (Debian)) id 18Ymoj-0001iY-00; Wed, 15 Jan 2003 13:38:49 +0100 Original-Received: from mdj by linnaeus with local (Exim 3.36 #1 (Debian)) id 18Ymog-0000Ps-00; Wed, 15 Jan 2003 13:38:46 +0100 Original-To: Clinton Ebadi In-Reply-To: <200301121645.09362.clinton@unknownlamer.org> (Clinton Ebadi's message of "Sun, 12 Jan 2003 16:45:09 -0500") User-Agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i386-pc-linux-gnu) Original-cc: guile-user@gnu.org X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: General Guile related discussions List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.user:1560 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:1560 Clinton Ebadi writes: > On Friday 10 January 2003 05:12, Mikael Djurfeldt wrote: >> Clinton Ebadi writes: >> > I think %modify-instance and -class should be public. >> >> Could you be more specific why? These seem pretty strange and magical >> to me, and might change as the implementation evolves... > > They swap the class in place. It seems that if I don't do that then > all of my objects that point to the class being changed remain being > part of that class and then only new objects can be created with the > changed class. My understanding of the MOP is a bit fuzzy so I'm > probably wrong. class-redefinition sets things up so that any future reference to an object of the old-class will cause it to switch to the new class. This means that from the moment (class-redfinition old new) is called, all objects of class old will appear as being of class new. The actual update takes place "just-in-time". >> > I specialized change-class and change-object-class (to the same >> > thing, just to be safe because the manual says either one may be >> > called but not both). >> >> The manual shouldn't mention change-object-class since that is a >> private part of the implementation. Yes. I've changed that now. >> Could you please give me enough information to reproduce the infinite >> loop you are talking about? > > My code is at http://unknownlamer.org/files/temp/serialize.scm (it > has other problems and after I get the class redefinition to work it > still won't work but I'd just have to do one more thing). I modified > it and now it says slot 'object is unbound (I marked the line this > happens at in the source). I didn't want anyone to see it because > the code is a bit of a hack and sucks...(sorry for taking so long to > reply but I've had to put in really long shifts at work the last few > days) I don't understand why you need to use the class redefinition protocol in this case. BTW, (oop goops save) seems to do something related to what you want to do. Since I don't understand your code, I can't deduce the intended correct operation, so I can't understand what is not working correctly either. However, I did notice one bug: Your change-class method doesn't call (next-method). That is necessary. Here's a further example of the protocol in operation. That may give some hints: guile> (use-modules (oop goops)) guile> (define-class c () (x #:init-keyword #:x)) guile> (define o (make c #:x 3)) guile> (define-method (change-class (o c) (new )) (next-method) (format #t "~A: ~A\n" o (slot-ref o 'x))) guile> (define-class c () (x #:init-keyword #:x) (y)) guile> o #: 3 # guile> _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user