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
Mon Oct 1 15:00:27 PDT 2012


On Oct 1, 2012, at 2:44 PM, Norbert Lindenberg wrote:

> It might be useful to list all the observable features to which "valid instance of" might lead for a built-in BuiltIn.prototype, and check whether we want them for new built-ins:
> 
> 1) Object.prototype.toString.call(BuiltIn.prototype) returns "[object BuiltIn]".
> 
> True for ES5 objects, currently not true for ES Internationalization objects. Discussion so far inconclusive.

Also not true for: EvalError, RangeError, ReferenceError, SyntaxError, TypeError, and URIError

they are all spec'd to return "[object Error]" from toString

> 
> 2) BuiltIn.prototype has state that lets BuiltIn methods successfully operate on the object, at least as long as they don't modify the state.
> 
> True for ES5 objects, currently also true for ES Internationalization objects. This means Intl.Collator.prototype can be used as a Collator with default properties, which applications might find useful. Discussion so far inconclusive.
> 
> 3) The state mentioned in 2) is modifiable.
> 
> True for some ES5 objects (Array, Date, RegExp), not true for ES Internationalization objects. The discussion seems to conclude that modifiable prototype objects are a bad idea.
> 
> 4) Object.getPrototypeOf(BuiltIn.prototype) returns BuiltIn.prototype.
> 
> False for ES5 objects and ES Internationalization objects. This would lead to infinite loops when looking up properties that don't exist, and we probably don't want that.
> 
> 5) BuiltIn.prototype instanceof BuiltIn evaluates to true.
> 
> False for ES5 objects and ES Internationalization objects. The ES5 spec for instanceof relies on 4).
> 
> Any observable features I missed?

The relationship between the constructor and the prototype.  EG:  Builtin.prototype.constructor === Builtin


> 
> Norbert
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
> 



More information about the es-discuss mailing list