Must built-in prototypes also be valid instances? (Was: Why DataView.prototype object's [[Class]] is "Object"?)
Allen Wirfs-Brock
allen at wirfs-brock.com
Sat Sep 29 21:55:00 PDT 2012
On Sep 29, 2012, at 7:23 PM, Rick Waldron wrote:
> ...
>
> Subjectively, the examples here are exactly how I would expect (hope?) this to behave, as the existing behaviour:
>
> > Array.prototype.push(1)
> 1
> > Array.prototype
> [ 1 ]
>
>
> ...Has always been seemed "strange" ;)
>
I believe this is the root item we are discussing. The legacy precedent says that Map.prototype.set("screwed", "you") should work and create an accessible map entry.
I specified Map.prototype to throw.
>
>
>
>
>
>
> Your change requires implementations to provide a different built-in class (constructor/prototype) initialization path. That's not desirable _per se_. Neither IMHO is the user-facing semantic split among "old" and "new" constructors.
>
> There are two separate issues here:
>
> 1. Should Map.prototype be an instance (firstborn for its realm) of class Map?
>
> 2. Should Map.prototype be a key/value store that can be used or abused as any other Map could be?
>
> We should not mix these up. SpiderMonkey (and possibly V8, I haven't tested) says "yes" to 1 and "no" to 2.
>
> 1: yes
> 2: no
>
As I covered in my reply to Brendan, I don't think these are sufficiently defined to really answer. But if you definition of "an instance" is that Object.prototype.toString.call(Map.prototype) returns "Map" then the latest spec. draft does 1: yes, 2: no
Allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120929/e086f374/attachment-0001.html>
More information about the es-discuss
mailing list