Mark S. Miller
erights at google.com
Wed Feb 17 16:53:34 PST 2010
On Wed, Feb 17, 2010 at 3:49 PM, Tom Van Cutsem <tomvc at google.com> wrote:
>> 5) I've lost track of where Harmony is heading with classes, but do you
>> have any thoughts on that? Do you see you traits as an alternative to any
>> other class proposal, or would it be intended as an extension of classes (as
>> the original traits proposal was), should they ever arrive?
> I'm glad you ask this question. To be frank, I don't see what benefits
> classes would bring in addition to traits.
> 1) As a unit of code reuse, trait composition is more flexible than class
> 2) As a unit of encapsulation, closures are more flexible than private
> instance variables.
> 3) As a unit of instantiation, 'maker' functions are more flexible than
> class constructors.
> 4) As a unit of implementation sharing, traits have the same properties as
> classes, given a trait-aware implementation.
> 5) As a unit of classification, interface types are more flexible than
> class types (of course ES doesn't have interfaces, so I think a solid
> object-type-testing mechanism would be a more useful addition to ES than
> classes would be).
[Numbers added to list entries above]
Hi Tom, I love the elegance of this answer. I agree with your conclusion,
and I agree with the above list regarding Java-like, Smalltalk-like, or
ES4-like classes. However, on points #2 and #3, your traits proposal is
identical to my classes-as-sugar proposal.
> In the original traits model, since traits are stateless, classes play an
> additional role not fulfilled by traits: carrying instance variables.
> However, in an extended trait model such as this one that allows traits to
> define instance variables as well as methods, traits can now take over this
> role from classes as well.
> Please do correct me if I'm missing a role for which classes do provide
> significant added value.
>> P T Withington
>> OpenLaszlo.ORG/Laszlo Systems
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss