[Bug 14877] Define [[Class]] of interface prototype objects, exception interface objects, and exception interface prototype objects

http://www.w3.org/Bugs/Public/show_bug.cgi?id=14877

--- Comment #15 from Garrett <dhtmlkitchen@gmail.com> 2011-11-23 17:47:10 UTC ---
(In reply to comment #14)
> (In reply to comment #12)
> > Allen should weigh in here. As noted, [[Class]] is not a supported extension
> > mechanism for other specs. We should negotiate a more future-proof way to spec.
> 
> It's not?  ES5 says:
> 
> """
> The value of the [[Class]] internal property of a host object may be any String
> value except one of "Arguments", "Array", "Boolean", "Date", "Error",
> "Function", "JSON", "Math", "Number", "Object", "RegExp", and "String".
> """
> 
> That suggests to me that specs defining the behavior of host objects are
> allowed to give them any [[Class]] they want except for that fixed list.  If
> this isn't the intent, the definition of String.prototype.toString has to
> change to add a different extension point.
> 
> (In reply to comment #13)
> > Right, thanks.
> > Though what I was getting at was that "The Function prototype object is itself
> > a Function object". 
> 
> The Function constructor object (Function) is a Function object -- Function
> instanceof Function is true.  The Function prototype object
> (Function.prototype) is not a Function object, it's a regular Object object --

No, the Function prototype object is itself a Function object. (sic)

> Function.prototype instanceof Function is false, Function.prototype instanceof
> Object is true.  See section 15.3 in ES5: http://es5.github.com/#x15.3
> 
That's on the FUnction constructor. Instead, see the section on
FUnction.prototype: http://es5.github.com/#x15.3.3.1 Which states "The Function
prototype object is itself a Function object". 

Function.prototype is useful for a reusable noop function and I've used it this
way a lot in my code! Instead of having : var noop = function(){}; Saves some
clutter. Though beware, while Function.prototype 
 is a function, it is not specified to implement [[Construct]] (same with
parseInt, etc). "None of the built-in functions described in this clause that
are not constructors shall implement the [[Construct]] internal method ".

> > The third line is a suggestion of what might happen if the suggested change is
> > made. As you've pointed out with Function.prototype, that too would not make
> > sense.  The idea suggested was what if DOMException.prototype is a DOMException
> > object. My mistake was using the instanceof operator here.
> 
> It amounts to the same thing.  The DOMException prototype is, as the name says,
> only a prototype for DOMException objects, in that all DOMException objects
> inherit its properties.  It is not a DOMException itself, and treating it as
> one would be inconsistent with how ES5 built-ins work.
No, you're wrong on that one. That quote I wrote is from the same spec.  I had
a blunder with instanceof, sorry, but I was his is how all the built-ins work.
I already quoted Function.prototype twice. Here's a few other built ins,
followed by my proposed suggestion.

15.5.4 Properties of the String Prototype Object # &#9417; &#9398;
The String prototype object is itself a String object (its [[Class]] is
"String") whose value is an empty String.

15.6.3.1 Boolean.prototype # &#9417; &#9415;
The initial value of Boolean.prototype is the Boolean prototype object
(15.6.4).

15.11.4 Properties of the Error Prototype Object # &#9417; 
The Error prototype object is itself an Error object (its [[Class]] is
"Error").

What I was trying to suggest was a proposal as such:
The DOMException prototype object is itself a DOMException object (its
[[Class]] is "DOMException").

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

Received on Wednesday, 23 November 2011 17:47:20 UTC