extends null

Jordan Harband ljharb at gmail.com
Sun Feb 15 11:34:14 PST 2015


Rather than making "extends null" alone a runtime error at class evaluation
time, is there a reason not to instead, make only a reference to "super" in
the constructor of a class that extends null be a runtime error at class
evaluation time?

On Sun, Feb 15, 2015 at 11:12 AM, Mark S. Miller <erights at google.com> wrote:

>
>
> On Sun, Feb 15, 2015 at 11:01 AM, Kevin Smith <zenparsing at gmail.com>
> wrote:
>
>>
>>> Interesting. I have never seen this pattern and don’t see what it could
>>> be good for. Thus, a dynamic error at class definition time sounds good to
>>> me.
>>>
>>
>> The purpose would be defining a class whose instances don't have
>> Object.prototype on their prototype chain.  If "extends null" doesn't work,
>> then I think you'd have to do something like this to achieve the same?
>>
>>     function NullBase() {}
>>     NullBase.prototype = Object.create(null);
>>
>>     class C extends NullBase {}
>>
>>
> That still wouldn't work at runtime because of the super semantics of C as
> a derived class. Instead
>
>
> class C {....}
>
> C.prototype.__proto__ = null;
>
> Yes, it is ugly, but it is an odd case, so still obeys Kay's dictum:
>
>
> "Simple things should be simple. Complex things should be possible"
>     --Alan Kay
>
>
>
>
>
> --
>     Cheers,
>     --MarkM
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150215/49ce2a3d/attachment.html>


More information about the es-discuss mailing list