On Wed, Oct 5, 2011 at 10:48 AM, John J Barton
<johnjbar...@johnjbarton.com>wrote:

>
>
> On Wed, Oct 5, 2011 at 12:52 AM, Tom Van Cutsem <tomvc...@gmail.com>wrote:
>
>> Thanks for the feedback, John.
>>
>> I have to admit that at first I was also taken aback by the apparent
>> complexity of the "syntax for efficient traits" strawman. Traits have many
>> knobs, and require a lot of syntax to turn these knobs.
>>
>> Regardless of whether you'd want nice declarative syntax for traits for
>> the sake of usability, for traits.js in particular, there's another
>> important benefit to having some language support. When using Trait.create
>> to create "tamper-proof" objects whose methods have an unspoofable
>> |this|-binding, the traits.js library creates a method wrapper per method
>> per instance (to bind |this| to the instance). I still need to verify how
>> much overhead this actually creates, but there definitely is overhead, and I
>> don't see any way to avoid it without some support from the language.
>>
>
> Yes I sensed your anguish about this issue. However I believe experimental
> measurements might surprise you. Lots of JS code involves event handlers
> passed into DOM calls. I bet lots of JS code already duplicates methods and
> bind |this|.  Only when you have many instances will this overhead matter,
> and in those cases I think you might be better off without OOP anyway.
>


It's been measured:
https://mail.mozilla.org/pipermail/es-discuss/2010-September/011821.html
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to