- From: Allen Wirfs-Brock <allen@wirfs-brock.com>
- Date: Tue, 23 Aug 2011 16:20:28 -0700
- To: Cameron McCormack <cam@mcc.id.au>
- Cc: Geoffrey Sneddon <gsneddon@opera.com>, public-script-coord@w3.org
- Message-Id: <CB105D21-CFBD-47BD-B8C0-CF014300CC44@wirfs-brock.com>
On Aug 23, 2011, at 2:48 PM, Cameron McCormack wrote: > > Otherwise I need to duplicate the native Function object internals [[FormalParameters]] and [[Code]] so that the 13.2.1 [[Call]] would work? OK, I see that. > > If we do change Window methods to bind to their original window object, then we could instead say that the values of the properties are Function objects that you'd get by calling .bind(<global>) on them. Then we don't need to have any custom [[Call]] behaviour. > Well you already have a [[Call]] method defined in 4.7.5. However I think step 7 should be something like: 7 Invoke the [[Call]] internal method of the native or host function object that implements operation op with idlarg0..m−1 as the argument values and with the same this value. For, host object implemented functions the op [[Call]] method is simply the implementation of the specified operations. You probably also need to specify ECMAScript to WebIDL value conversions for the this value because call and apply permit any function to be called with arbitrary this values. Normally for ES built-in functions any special processing of this values including converting undefined to the global object is part of the algorithmic specification of the function. You could use an extend attribute to to specify this processing conversions. However, I'd be real careful about which functions you specify as automatically translating undefined to the Window object. It probably makes sense for alert and probably some other functions but you really need to be selective or you risk ambient exposure of the global object. Also, ES consistency for such cases would use the global object of the context that the function originated in. Finally, keep in mind that in practice any ECMAScript native implementation of a WebIDL operation isn't going to actually have a [[Call]] internal method as defined in your 4.7.5. Instead, it is going to be directly invoked using the ES5 13.2.1 [[Call]] it it is going to be up to the ECMAScript code within the function to do the work defined in 4.7.5 (include the overload dispatch). Allen
Received on Tuesday, 23 August 2011 23:21:09 UTC