[pro] Modularity for subclassing in Common Lisp

Scott McKay swm at itasoftware.com
Wed Dec 8 13:46:39 UTC 2010


On Dec 7, 2010, at 11:10 PM, Matthew D. Swank wrote:

> On 12/07/2010 09:19 PM, Faré wrote:
>> A better question might be
>> how do you enforce disjointness of some mixins. I suppose a
>> heavy-handed use of MOP magic could do it, but oh well.
> Q: Doctor, it hurts when I do this.
> A: Well, don't do that.
> 
> In the examples I looked at that inspired me to use IPS (<map> might
> have been one), sets of mixins partition (part of) a default
> implementation, and most of methods specialize only on interface types. 
> As a whole, the parts of the protocol implemented by a set of mixins
> depend only the unimplemented generic functions, and not on any
> particular datatype. Kinda a Ruby Module-y, Smalltalk Trait-y sort of
> thing. 
> 

This is how I use mixins, too -- as "trait"-y sort
of things that provide implementation of a protocol,
but don't "contribute" to the type.  That is, there
is a single-inheritance "backbone" that may, or may
not, have implementations of the protocol(s), and
zero or more mixins that provide bits of implementation.
I tend to avoid having mixin classes provide any public
slots, although there may be internal slots to aid in
the implementation.

Just my two cents...





More information about the pro mailing list