[closer-devel] Slot definition inheritance

Gary King gwking at metabang.com
Tue Mar 7 16:49:18 UTC 2006


FWIW, there is a not perfect implementation of this sort of thing in  
the metabang-dynamic-classes ASDF system (which is really part of  
metatilities. It includes simple-define-class and define-class. Both  
of these just create classes and don't worry about caching. It also  
includes a system to map initargs to mixins which can be used to  
build classes as necessary. These are cached. As an example, here is  
some code from CL-Containers. First, I tell dynamic-classes which  
subclasses are necessary for various initargs:

(add-parameter->dynamic-class :iterator :transform 'transforming- 
iterator-mixin)
(add-parameter->dynamic-class :iterator :filter 'filtered-iterator- 
mixin)
(add-parameter->dynamic-class :iterator :unique 'unique-value- 
iterator-mixin)
(add-parameter->dynamic-class :iterator :circular 'circular-iterator- 
mixin)

Now when I make an iterator, I get a different class depending on  
what I ask for...

(class-of (make-iterator '(1 2 3 2 4 5) :filter #'oddp))
==> #<STANDARD-CLASS FILTERED-ITERATOR-MIXIN-AND-LIST-ITERATOR>

(make-iterator '(3 2 4 1 3 2) :filter #'oddp :unique t)
==> #<STANDARD-CLASS FILTERED-ITERATOR-MIXIN-AND-UNIQUE-VALUE- 
ITERATOR-MIXIN-AND-LIST-ITERATOR>

I don't have a great sense of what the cost of this machinery is  
(though it is small enough that I use it quite a bit without feeling  
any pain).

The package can be downloaded via ASDF-Install or found on  
metatilities home page (http://common-lisp.net/project/cl-containers/ 
metatilities/).

If you do look at the code, it will be obvious that it is a somewhat  
decrepit state. I hope to remedy that sometime real soon. If there is  
any interest, real soon may occur faster than if not! <smile>

HTH

On Mar 7, 2006, at 11:22 AM, Pascal Costanza wrote:

>
> 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.


-- 
Gary Warren King
metabang.com
http://www.metabang.com/





More information about the closer-devel mailing list