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.
Thanks in advance
Albert


|