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

Brendan Eich brendan at mozilla.org
Sat Sep 29 22:24:57 PDT 2012


Mark S. Miller wrote:
> Security aside, given maximin
>
>     class Foo
>
> what do you suggest Foo.prototype be?

If classes are sugar for constructor functions, an Object instance, just 
as you'd get for

   function Foo(){}
   Foo.prototype

There has always been an unsightly difference between built-in 
constructors and user-defined ones. Whether or how we reduce that gulf 
is separable from what the [[NativeBrand]] or [[Class]] of a built-in's 
prototype should be.

When self-hosting built-ins, this matters. Suppose [[NativeBrand]] could 
be a symbol private to the built-ins. That would allow the engine to set 
up bespoke-looking prototypes as it needs to for ES1-5 compatibility. 
But should user-defined classes have access to this symbol?

/be


More information about the es-discuss mailing list