W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2014

Re: Typeconverting Exotics

From: Allen Wirfs-Brock <allen@wirfs-brock.com>
Date: Sun, 12 Jan 2014 15:30:21 -0800
Cc: "public-script-coord@w3.org" <public-script-coord@w3.org>
Message-Id: <4729E919-60BF-44C5-8EE2-54B14578F0DC@wirfs-brock.com>
To: Garrett Smith <dhtmlkitchen@gmail.com>

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

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:37:51 UTC