Must built-in prototypes also be valid instances? (Was: Why DataView.prototype object's [[Class]] is "Object"?)

Rick Waldron waldron.rick at gmail.com
Mon Oct 1 13:14:33 PDT 2012


On Mon, Oct 1, 2012 at 4:04 PM, Brendan Eich <brendan at mozilla.com> wrote:

> Rick Waldron wrote:
>
>  On Mon, Oct 1, 2012 at 3:21 PM, Brendan Eich <brendan at mozilla.com<mailto:
>> brendan at mozilla.com>> wrote:
>>
>>     Andreas Rossberg wrote:
>>
>>         Er, from my reading that's clearly not what the Wiki says for
>>         WeakMap. And it also is not what V8 implements, for either
>>         WeakMap or Map.
>>
>>
>>     Sorry, I was relying on Rick's testimony that the answers were 1)
>>     yes, 2) no.
>>
>>
>>
>> Yes, when I first considered the topic, it seemed to make some kind of
>> sense (based on a desire for consistency), but I also don't believe that
>> should be the case now—I even noted that I had always subjectively viewed
>> resulting behaviours as "strange".
>>
>
> Oops, then I really misread one of your messages -- I thought you had
> tested in V8.
>
>
I did, via node, but I was showing Array, not Map—Erik showed Map, which is
the built-in "that disagrees" :)



>
>  I'm not sure I've ever encountered code in the wild that made any
>> intentional use of built-ins Foo.prototype-as-firstborn - can anyone on the
>> list point to some compelling use cases?
>>
>
> If it doesn't matter, we could make all the built-ins'
> constructor.prototype objects be instances of Object (except for the Error
> subclasses!).
>

Is there any way to confirm?


Rick


>
> That would be nice. Then we'd have
>
>   class C extends B {}
>   assert(C.prototype instanceof B)
>
> and per Allen's nifty trick of avoiding class-side inheritance from Object
> (which made Dave hear angels sing):
>
>   class C {}
>   assert(C.prototype instanceof Object)






>
>
> /be
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121001/bf588ca2/attachment.html>


More information about the es-discuss mailing list