Albert Krewinkel wrote:
> Hi,
>
> during the last few days, I repeatedly encountered situations in which a
> lot of functionality is provided using CLOS mixins. A well know example
> of this is Sonja Keenes CLOS implementation of streams:
> input/output/bidirectional streams for disk/tape and element-type
> 8-bit-byte/32-bit-word/character. To allow for all possible
> combinations of direction, device-type and element-type, there is a
> total of 15 instantiable cl***** (no bidirectional streams for tapes).
>
> In the process of defining these 15 cl*****, 27 more have to be defined,
> such that the 15 can be build by inheriting from those. Most of the
> total 42 cl***** don't even define any additional slots. Writing them
> results in a lot of boilerplate.
>
> This observation made me think of possible simplifications in this
> process: I feel like there's missing some method to generate "cross
> products" of inheritance trees/graphs. Let me explain using the example
> of disk streams:
>
> Streams have a basic class layout of the following form:
>
> stream
> / \
> input-stream output-stream
> \ /
> bidirectional-stream
>
>
> Now instead of having to write all disk-streams following the above
> scheme by hand, I'd like to be able to do
>
> (define-cross-product-cl***** stream-class-graph disk)
>
> and thereby get all the above stream cl***** s/stream/disk-stream/g
> Finally, all that's left to do is
> (define-cross-product stream-cl***** device-cl***** element-types)
> and - magic - all necessary cl***** are generated. Only those with
> additional slots would have to be defined by hand.
>
> Now this doesn't seem easy, but I'm currently facing an application
> where this would be more than usefull. It would also make such schemes
> more easily extensible, since one doesn't have to remember which
> intermediate cl***** one has to write: Just define another device-type
> and apply the crossproduct -- done.
>
> Has that ever been done before? Are there any research papers I should
> look at? This is more complex than I thought, so any help is highly
> appreciated.
I recall a "capabilities" project that sup****ted dynamically mixing and
unmixing in cl*****, I guess that would sup****t what you want. I have
not found in recent searches, but others here have talked about using
the mop for this so you'll probably get more useful info soon.
I will be here reminding you not to lock into CLOS as a key component of
your eventual solutio:, Lisp is a big language with lotsa ways of doing
things. I am made especially nervous by the idea of "the ones needing
slots" getting special handling.
btw, if you just need all the combos combinated (?), take your define
cross-product macro and have it combinate the mixins listed at macro
expansion time and just have that emit one big progn of defcl*****, one
per combo (I am sure you jsut need unique combos). Then this geenrator
can take a following list of specifications in the form:
(slots (<specific mixins>+)
<slots-needed>+)
When the huge class combinator is generating each class it can peek at
the "slots" specifications to see if there is a match and throw those
slots in at the same time.
kt
ps. come to think of it, I am surprised a /combination/ of mixins needs
a new slot, sounds like you will not really get all you need from this
mixology, which brings me back to warning you against locking in too
soon on this approach. k
--
http://smuglispweeny.blogspot.com/
http://www.theoryyalgebra.com/
ECLM rant:
http://video.google.com/videoplay?docid=-1331906677993764413&hl=en
ECLM talk:
http://video.google.com/videoplay?docid=-9173722505157942928&q=&hl=en


|