Re: Typeconverting Exotics

On Jan 12, 2014, at 12:39 PM, Garrett Smith wrote:

> Exotics are host objects that can implement non-standard behavior.

Well, that's not a totally correct definition of exotic object. 

EcmaScript 6 introduces the terminology "ordinary objects" and "exotic objects" [1].  An ordinary object is any objet that implements the default object semantics.  These semantics are those that correspond to the object essential internal methods [2] behavior as defined in [3].  An exotic object is any object that use a different definition (from that given in [3]) for at least one of the essential internal methods.  

Being exotic is not specifically connected with being a "host object".  (ES6 does not use or define the term "host object").  If a host provides objects that support the standard essential internal method semantics, those objects are host objects.  Similarly, some standard ES objects (for example Arrays and Proxy objects) are exotic objects.

Where ever the WebIDL ECMAScript binding requires alternative semantics of any of the essential internal methods , it is defining an exotic object.  However, in many other situations  a host provided object can just be an ordinary object

> 
> For example, in Firefox:
> 
> typeof document.all == "undefined"; // true
> undefined == document.all;   // true
> undefined === document.all; // false
> "all" in document; // true
> Object.getPrototypeOf(document).hasOwnProperty("all"); // true
> 
> Consistent results are generally desirable. I'm just thinking of
> [[ToBoolean]], [[ToPrimitive]], and [[HasProperty]]. Should it be
> spec'd? Should exotics masqueraded as undefined, be typed
> Exotic(null|undefined)?

I don't believe that the semantics of document.all can expressed solely in terms of the essential internal methods.  It also requires special case changes to ToBoolean, typeof, and probably some other language-level operators. 

Allen



[1] http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object-type 
[2]: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object-internal-methods-and-internal-slots 
[3]: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-ordinary-object-internal-methods-and-internal-slots 

Received on Sunday, 12 January 2014 23:30:56 UTC