On Fri, Aug 25, 2006 at 01:25:23PM -0700, Trey Harris wrote: : I think Larry nailed it with his observation about the difference between : class and role and trait. 'Constant' is a trait of another type, not a : type into itself.
Hmm, well, there are several hands to be waved here. First, there's more than one kind of constancy. Some types are intrinsically immutable, some are immutable by compile-time declaration, some are just immutable by contract, while others are operationally constant because you never happen to call any mutators. I'd like to distinguish the latter by calling it "readonly" rather than "constant" or "immutable". The big handwave about roles is that they can simultaneosly serve as your abstract array and your concrete default implementation through the magic of class/role punning. (It occurs to me that we probably need to nail down the genericity (or lack thereof) of PRE and POST blocks when attached to roles rather than classes. But in theory roles are allowed to participate in DBC, I think.) The big handwave about subsets is that they are basically defined operationally rather than contractually. When I use a subset type, the constraints are something I'm enforcing on myself, not something enforced by the underlying base class. The actual class knows nothing about my personal hangups. An Odd is only odd to me, not to the value, which only knows it's an Int. You don't do DBC with subsets. You're just being extra-disciplined outside of any contractual agreements. That's how I see it, anyway. Larry