Must built-in prototypes also be valid instances? (Was: Why DataView.prototype object's [[Class]] is "Object"?)
brendan at mozilla.org
Mon Oct 1 15:58:43 PDT 2012
Allen Wirfs-Brock wrote:
>> Any observable features I missed?
> The relationship between the constructor and the prototype. EG: Builtin.prototype.constructor === Builtin
Right! I forgot this a minute ago after showing how CoffeeScript does
I am warming up to the way CoffeeScript does things -- not the
translation scheme, __extends, __super__ -- rather, the plain Object
instance created as C.prototype that has B.prototype as its
[[Prototype]] but has shadowing 'constructor' set to C.
With a rule to set @@toStringTag by default (or not), and some attempt
to match legacy built-ins (I'm thinking about trying this on in
SpiderMonkey), we might have a regular set of rules for this stuff.
The safest course might still be to set @@toStringTag to "C" in
C.prototype, along with 'constructor'. That would fake things up to
match legacy built-ins except where they provide a communication channel.
I'd still want to close that channel, by making Date.prototype a
dressed-up Object instance. But this would be less risky than making its
tag-testable "class name" be "Object".
More information about the es-discuss