W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2010

Re: [WebIDL] interface objects with [Constructor] and [[Call]]

From: Garrett Smith <dhtmlkitchen@gmail.com>
Date: Thu, 7 Oct 2010 22:26:09 -0700
Message-ID: <AANLkTi=3TSqRzaU2Fba6+gvS=6Gi4BpxZMbQMAOciPiH@mail.gmail.com>
To: Garrett Smith <dhtmlkitchen@gmail.com>, "Mark S. Miller" <erights@google.com>, Maciej Stachowiak <mjs@apple.com>, James Graham <jgraham@opera.com>, Travis Leithead <travil@microsoft.com>, Simon Pieters <simonp@opera.com>, "public-script-coord@w3.org" <public-script-coord@w3.org>, annevk@opera.com
On 10/7/10, Cameron McCormack <cam@mcc.id.au> wrote:
> Garrett Smith:
>> ECMA-262 [[Construct]] requires the target object to have a [[Call]]
>> property. It appears that you may have been misled by Maciej
>> Stachowiak's comment:
>> "Another possibility when there are no legacy constraints is to not
>> implement [[Call]], so that there is only one way to invoke the
>> constructor."
>> The problem with that statement is that the algorithm for
>> [[Construct]] invokes the object's [[Call]] property and so if the
>> new'd object does not implement [[Call]], then a TypeError would
>> result.
> Is that just for native Function objects, or for host objects as well?
> I see that the native Function object [[Construct]] (section 13.2.2 of
> ES5) calls [Call]], but I couldnít find a requirement that host objects
> that implement [[Construct]] must also implement [[Call].

My statement in the previous paragraph is regarding the algorithm for
[[Construct]], as specified in ECMA-262. Were you discussing a
different [[Construct]]?

In ECMA-262, step 6 of [[Construct]] is:
| 6. Invoke the [[Call]] property of F, providing Result(1)
| as the this value and providing the argument list passed
| into [[Construct]] as the argument values.

Understand that an object that implements [[Construct]] implements
[[Call]]. What is not known is what either of those commands will do.
That is what specification is for.

How can an object implement [[Construct]] but not [[Call]]?

I get what you're after here, you want to specify that certain
constructors throw a TypeError if not invoked via [[Construct]]. So
its just a matter of putting that into specification terminology.

> For consistency, since thatís always the case with the built-ins, itís
> probably a good idea.  Of course, you could always implement [[Call]] as
> just:
>   1. Throw a TypeError.
> :)
No, because then [[Construct]] would, by implication, have that effect
as well ([[Construct]] -> [[Call]] -> TypeError).

It seems you want to say: "When [XXX] is called as a function the
result is a TypeError."
Received on Friday, 8 October 2010 05:26:49 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:02 UTC