Classes as Sugar is now ready for discussion

Mark S. Miller erights at google.com
Thu Sep 9 22:41:21 PDT 2010


On Fri, Sep 10, 2010 at 5:30 AM, David Herman <dherman at mozilla.com> wrote:

> IIUC, with Object.create, you don't even get the conflict checking. And
>> then you've really lost the key benefit of traits.
>>
>
> See <
> http://code.google.com/p/es-lab/source/browse/trunk/src/traits/traits.js#150>.
> Even with Object.create, you still get conflict detection, but with failure
> postponed from creation to usage. This is a more traditionally JavaScripty
> way to report failure anyway.
>
>
> Ah, I see. I missed that part.
>
> Is the on-demand nature of conflict detection (for traits built with
> Object.create) somehow unavoidable, or was that simply a design choice?
>

It actually was a design choice dating from before we switched to
Object.create. Originally, we had a high-vs-low integrity switch in
Traits.create. As Tom was implementing our design, he noticed that the low
integrity case simplified down to being identical to Object.create. Seeing
that, Tom realized that we didn't actually need a switch as people could
just use Object.create directly.

Tom, do I have the history of that right?


>
>     function Point(x, y) {
>       this.x = x;
>       this.y = y;
>     }
>     Point.prototype = Object.create(
>       SuperPoint.prototype,
>       Trait.compose(.....));
>
> Is that the kind of usage you had in mind?
>
>
> Yes, exactly. Sorry for my oversight.
>
> Dave
>
>


-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20100910/9e0c28c3/attachment.html>


More information about the es-discuss mailing list