Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!tut.cis.ohio-state.edu!BBN.COM!jkelly From: jkelly@BBN.COM Newsgroups: comp.lang.clos Subject: Re: accessing clos objects Message-ID: <9102141835.AA19768@cheops.cis.ohio-state.edu> Date: 14 Feb 91 18:31:47 GMT Sender: welch@tut.cis.ohio-state.edu Distribution: inet Organization: CommonLoops Lines: 112 I've used the metaclass approach to store instances, with pcl on a symbolics. Recently I recompiled in genera 8, which includes symbolics clos implementation. Doesn't quite work anymore however. Perhaps people are interested in the problem and symbolics' response. -Jim (I've removed the names, addresses of the people at symbolics. Don't think it's appropriate for me to include that without their consent (which I haven't solicited) as these were messages just between me and them. ----- Subject: make-instance, metaclass bug? From: jkelly@BBN.COM Date: Wed, 30 Jan 1991 11:19 EST I'm trying to define a metaclass which keeps a list of its instances. This worked fine in genera 7.2 but doesn't completely seem to work in 8.0.1. If you could let me know how to get around the problem I'd appreciate it. Thanks, -Jim ;; The following gets compiled and loaded: (defclass CLASS-WITH-INSTANCES (standard-class) ((instances :initform nil :accessor class-instances))) (defmethod MAKE-INSTANCE :around ((class CLASS-WITH-INSTANCES) &rest ignore) (let ((instance (call-next-method))) (push instance (class-instances class)) instance)) (defclass class-with-instances-test () () (:metaclass CLASS-WITH-INSTANCES)) (defun foo () (make-instance 'class-with-instances-test)) ;; As follows make-instance doesn't work when called within a function: Command: (make-instance 'class-with-instances-test) # Command: (class-instances (find-class 'class-with-instances-test)) (#) Command: (foo) 1Error: INTERNAL ERROR: FAST-P true but 0 1(CALL-METHOD # (#)) occurred unexpectedly CLOS-INTERNALS::VERIFY-FAST-P 0 Arg 0 (GENERIC-FUNCTION): # Arg 1 (CLOS-INTERNALS::PRIMARY-CALLED): NIL Arg 2 (CLOS-INTERNALS::FAST-P): T Arg 3 (CLOS-INTERNALS::FORM): (CALL-METHOD # (#)) s-A, : Return to Breakpoint ZMACS in Editor Typeout Window 9 s-B: Editor Top Level s-C: Restart process Zmacs Windows 2 ----------------------- Date: Mon, 11 Feb 1991 12:59-0500 Subject: [jkelly@BBN.COM: make-instance, metaclass bug?] "It's a constructors bug. It still happens in 8.1. There's no need to be using a metaclass to do this kind of thing; a mixin with an after method on shared-initialize would do the job." In addition, the following comments come from another developer here. I'm not sure how applicable they are to your problem, but I thought I should include them. We do not support metaobject protocol (a.k.a. MOP, a.k.a. "CLOS Chapter 3"). If you think something worked in 7.2 (which is before we introduced CLOS), our guess is that you don't maintain your own world but rather just uses a world that someone else has set up for you, and that probably in 7.2 you were loading PCL, which is where the meta-object protocol originated. Probably in 8.0 you switched to our CLOS, and got bitten because you were using all those chapter 3 things which are really not part of the CLOS that has been adopted by X3J13. The meta-object stuff may never be adopted as is - our guess is that it will change a lot as part of standardization efforts because other implementations will want to do some things differently; in some ways it's still believed to be too dependent on the PCL way of doing things. But in any case, it will almost certainly not appear in ANSI CL, and so is not something you will be able to depend on in portable code, and we'd recommend you not get hooked on it for the practical reason of leaving your code open to later porting. -----