traits are now impossible in ES6 until ES7 since rev32?

Kevin Smith zenparsing at gmail.com
Thu Feb 5 21:07:04 PST 2015


>
>
> Hopefully I’m wrong in that Foo.call(this) is illegal, but if it is, this
> is a devastating change, especially when traits are scheduled for ES7 or
> later.
>

Class constructors will now throw when called.

The changes to classes were fundamental but necessary to support
subclassing of builtins (and future extensions to classes).

For mixins, can you move the initialization logic into a method (or a
static method), instead of having it in the constructor?

    class M() {
        // methods
        static initialize(obj) { }
    }

    function ctor() {
        M.initialize(this);
    }

    // etc.

Is this a viable pattern for traits/mixins?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150206/28bec75c/attachment.html>


More information about the es-discuss mailing list