[closer-devel] Slot definition inheritance

Pascal Costanza pc at p-cos.net
Tue Mar 7 16:22:42 UTC 2006


On 5 Mar 2006, at 21:16, Nick Bourner wrote:

> Hi all,
>
> Not sure this is entirely on topic here, but it's a MOP question and
> I'm using closer-mop :-)
>
> Does anyone know how (or indeed if it is possible) to have a slot
> inherit from two different slot definitions, so that the effective
> slot definition is the union of the two direct slot definitions.
> There's code in section 3.5.2 of AMOP that seems like it would be
> possible by making an effective slot definition on the fly using
> "make-effective-slot-definition" but that doesn't seem to exist in
> SBCL or OpenMCL, or at least it isn't exported from wherever it's
> hiding.
>
> I have a suspicion I'm going to have to do this by making one slot
> definition a subclass of the other, but something like the AMOP stuff
> would sure be handy.
>
> Anyone know for sure?

Yes - that function doesn't exist.

The AMOP book uses different variations of a metaobject protocol  
throughout the book to make certain points clear. The only  
specification that's actually somewhat binding for CLOS are chapters  
5 and 6. There's no "make-effective-slot-definition" mentioned there.

BTW, an effective slot definition class shouldn't inherit from a  
direct slot definition class. Direct slot definitions are slots as  
they (conceptually) occur in a defclass form, while effective slot  
definitions are slots as they are inherited and possibly combined  
from a class and all its superclasses. It's important to keep these  
concepts separate.

A function that creates a subclass on the fly based on a list of  
classes to be inherited from could actually useful in other  
circumstances as well. So something like

(make-combined-instance '(a b c) ...)

could create a class with the direct superclasses a, b and c and then  
create an instance of that class. It would probably make sense to  
cache such implicitly created classes based on the list of direct  
superclasses in order to reuse existing combinations and not to waste  
too much space by creating too many of those combination classes.


Pascal

-- 
Pascal Costanza, mailto:pc at p-cos.net, http://p-cos.net
Vrije Universiteit Brussel, Programming Technology Lab
Pleinlaan 2, B-1050 Brussel, Belgium







More information about the closer-devel mailing list