Re: [langsmiths] Mixins, traits and horizontal composition
- Mike Austin scripsit:
> So on that note, I think traits can take the place of mixins, protocolsIt's also generally understood that traits don't have state: you create a
> (Obj-C) and even predicate classes, where an object can change behavior
> based on state. If traits were an array of horizontal objects (versus
> vertical with inheritance), Impulse traits would look very similar to
> Ruby's mixins:
class by listing its traits and its state variables. However, I've been
thinking about an alternative in which all state variables are private to
a trait, the idea being that since state variables couple all methods
that reference them, such that none should be replaced without replacing
all, it makes sense to think of that set of methods and associated
state variables as a trait, and then horizontally compose classes out of
these state-bearing traits. Given that, it is no longer necessary to
distinguish between classes and traits: incorporating a class is
equivalent to incorporating the traits that the class incorporates.
Is not a patron, my Lord [Chesterfield], John Cowan
one who looks with unconcern on a man http://www.ccil.org/~cowan
struggling for life in the water, and when cowan@...
he has reached ground encumbers him with help?