[closer-devel] Initargs of slot definitions: I miss COMPUTE-E-S-D-INITARGS

Pascal Costanza pc at p-cos.net
Thu Nov 23 22:14:24 UTC 2006


On 23 Nov 2006, at 17:31, Ivan Boldyrev wrote:

> I'd like to create metaclass where slot description class depends on
> slot's initargs.  However, EFFECTIVE-SLOT-DEFINITION-CLASS takes only
> class argument and initargs.  But initargs passed are just standard
> initargs like :name, :type etc.  I cannot pass other initargs to the
> E-S-D-C.
>
> Possible solutions:
>
> 1.  (Current) Special variable is bound by
>     COMPUTE-EFFECTIVE-SLOT-DEFINITION, and E-S-D-C just returns
>     variable's value.  It seems to be somewhat kludgey.
>
> 2.  Use one class for all types of slots.  But this is "anti-OOP"
>     solution.  As 1 is local kludge, 2 is global one (i.e. impacts
>     whole program).
>
> And one impossible solution:
>
> 3.  Change class of resulting slot definition with CHANGE-CLASS.  But
>     this is explicitly prohibited by MOP.
>
> Are there any other possible solutions?

I don't know whether there are other solutions, but you have listed  
all the ones that I know about.

Option 1 is the one that I use in my own code, for example in the  
implementation of special classes in ContextL. What I actually do is  
that direct slot definitions are always specialized according to the  
class metaobject class. So for a special-class, you always get  
special-direct-slot-definition metaobjects. This allows me to record  
any initargs for slots with the direct slot metaobjects. Only when  
the effective slots are created, I do this based on the list of all  
direct slot metaobjects in compute-effective-slot-definition.

I think option 2 would be ok in general, and I wouldn't mind much  
whether it adheres to any OOP principles or not. The more important  
reason to be more specific here is that calls to slot-xyz-using-class  
can be optimized away when the arguments are all of standard  
metaclasses. So I always try to use as few metaclass specialization  
as possible here.

I have seen option 3 being used in example code, even example code  
shown by Kiczales et al. In my opinion, the CLOS MOP specification is  
overly strict here - maybe a copy&paste issue in the spec, I don't  
know. Anyway, that's the reason why I don't use option 3 either.

> As I cannot change initargs of effective slot, I also have to set some
> slots in COMPUTE-EFFECTIVE-SLOT-DEFINITION after calling
> CALL-NEXT-METHOD.

Exactly.

> It is so pity that COMPUTE-EFFECTIVE-SLOT-DEFINITION-INITARGS is not
> part of the MOP.  As I checked, C-E-S-D-I is defined in CMUCL/SBCL,
> LispWorks, Allegro CL and Clisp (where it is exported symbol).  Is it
> worth making CLOSER-MOP-EXT package where useful extensions like
> C-E-S-D-I are collected?

Are they documented anywhere?

> P.S.  Pascal, I have read your paper, but didn't quite understand it,
> mostly because of poor knowledge of subject and difficulty of reading
> English.  So, no feedback yet, sorry.

No problem at all. Thanks for reading it. ;)


Cheers,
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