On Tue, Jun 24, 2014 at 10:36 AM, Raoul Duke <[email protected]> wrote:
> yeah, so what are the alternatives that work at least as well if not > better? I'll take a stab, at least obliquely: interfaces. Let me say that differently. I think that *encapsulation* is essential, and that there is real value in being able to gather common sets of functions together in a nameable way (which would be the interface). Where we seem to get in trouble in OO is when we mix this stuff up with hierarchies, and even more so when we go and mix the hierarchies up with the implementations. The counter-examples (to my statement) that I've seen fall into two categories: 1. False hierarchies, like the Number hierarchy in Smalltalk. It's a conceptual hierarchy. Sort of. Maybe. But it makes very little sense as a type hierarchy or a formal mathematical hierarchy. It's best thought of as *ad hoc* polymorphism with an unusually dense lattice of relationships between the types. Actually, I think that the Number class subtree in Smalltalk did some damage to OO by being a really bad example. Though not any damage we would have failed to reinvent otherwise. 2. Bounded heterogeneity. I need to put a bunch of things with some common behavior into a collection, and I need to be able to get them out again in their original forms. What ends up happening in practice is that I design a superclass that implements the common interface, and then I use [hopefully checked] dynamic downcast. Well why not use interfaces for that? I *would* say, very provisionally, that hierarchies seem to work better in bounded quantification (type classes). But I think this is because the way they have been used to date follows the traditions of mathematics and category theory. Thus (Ord x) <: (Eq x) seems sensible, because indeed all thing that have a total order must have a definition of equality. My intuition is that type classes have mostly been used to describe operational relationships without conflating implementation, and that this yields a cleaner outcome. It's an open question in my mind whether proliferation of type classes won't ultimately follow the path of woe that subclasses have followed. Hard to know. Jonathan
_______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
