On Monday, December 16, 2002, at 06:47 PM, <[EMAIL PROTECTED]> wrote:
> > > I was wondering if anyone could put me straight about the PRAGMATICS > of using metaclasses with CMUCL and PCL. Here's the deal: I have some > code that I'd like to use with CMUCL. That code is currently used > happily with Franz' Allegro CL. The code makes some use of > metaclasses. Not extensive use, but some. In general the PCL MOP support is quite good. The only trick is that you want to use pcl:find-class, pcl:class-of, pcl:class-name and pcl::standard-class instead of the CL versions. > > Consider an example: There's a metaclass we'll call MY-CLASS that has > a couple of features to it, most importantly being that any class that > has that class as its metaclass, will track all of its instances, etc. > > So, for example, the metaclass has an instances slot: > > > (defclass my-class (standard-class) > ( > (instances :initform nil :accessor instances) > ) > ) Good so far... > > I've read the "Hints for using the PCL MOP" web page, and as far as I > could tell, in order to get from a class object to this instances > slot, I (believed I) had to interject the following method definition: > > #+cmu > (defmethod instances ((class standard-class)) > (instances (kernel:class-pcl-class class))) > > That's fine, but I don't see that I can shadow every single method on > my-class with a definition like the above. Especially since the code > will still be used with Allegro. > > Is there a standard workaround for this kind of thing? The key is to get the right metaclass by calling pcl:class-of on the CLOS object instead of cl:class-of. To avoid littering your code with #+cmucl you might consider doing what we do in McCLIM: don't use the common-lisp package, define own lisp package that imports/exports most symbols from common-lisp except those that need to be patched. Tim
