[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: around method for make-instance
- To: info-mcl-digest@cambridge.apple.com
- Subject: Re: around method for make-instance
- From: Ora Lassila <ora@ISL1.RI.CMU.EDU>
- Date: Sat, 20 Nov 93 12:11:08 EST
- Cc: ora@cs.cmu.edu
- In-reply-to: <info-mcl-digest-request@cambridge.apple.com>'s message of Sat, 20 Nov 93 04:00:04 EST <9311200900.AA12663@cambridge.apple.com>
I haven't really been following this discussion, but something caught
my eye:
Shannon V Spires <svspire@somnet.sandia.gov> writes:
> But if you just want to specialize make-instance (or any other method that
> takes a class as an argument) for a _single_ class, you have to use the
> (eql...) syntax because you're then defining a method on a single instance
> [of a metaclass].
Using EQL-specializers will not work if you create a subclass of the
class for which MAKE-INSTANCE has been specialized (obviously the
subclass is not eql to the superclass). This is where metaclasses can
be used. If you want to define a class (say, FOO) such that it has a
specialized MAKE-INSTANCE and all of FOO's subclasses also have this
specialized MAKE-INSTANCE, you have to define a new metaclass:
(DEFCLASS FOO-METACLASS (STANDARD-CLASS)
())
(DEFCLASS FOO ()
()
(:METACLASS FOO-METACLASS))
(DEFMETHOD MAKE-INSTANCE :AROUND ((CLASS FOO-METACLASS) &REST INITARGS)
...)
The problem is that all subclasses of FOO that are to share the new
MAKE-INSTANCE, also have to have FOO-METACLASS (or its subclass) as
their metaclass.
(This example ignores the fact that, according to AMOP, a
VALIDATE-SUPERCLASS method has to be defined for FOO-METACLASS. In MCL
this is not an issue.)
- Ora Lassila
The Robotics Institute
Carnegie Mellon University
ora@cs.cmu.edu