Coercing 'this' (was: Topic list - pending changes and issues for the ES3.1 spec)

Maciej Stachowiak mjs at apple.com
Mon Sep 15 20:05:00 PDT 2008


On Sep 15, 2008, at 7:51 PM, Mark S. Miller wrote:

> On Mon, Sep 15, 2008 at 6:16 PM, Brendan Eich <brendan at mozilla.org>  
> wrote:
> On Sep 16, 2008, at 1:54 AM, Mark S. Miller wrote:
>
>> This is also badly incompatible. Global functions are used as  
>> methods of their window objects. Calling them via this.func() or  
>> otherFrame.func() works, but so do calls to func() from the same  
>> window.
>>
>> Since there's only one window per JS global object (obviously,  
>> since they're the same object), all the methods of the window could  
>> already be bound to their window,
>
> You're proposing to bind |this| to all window functions in strict  
> mode?
>
> Worse. Since strict mode is only per program-unit, not per global  
> object (frame), it makes no sense for such binding to be specific to  
> strict mode. Rather, I'm proposing/asking whether it would be  
> noticeably incompatible if all browser-provided window functions  
> were bound to their window, period. Note that this need not be  
> implemented or specified in terms of a specific 'bind' operation. It  
> suffices to define all the browser-provided widow functions to refer  
> to their window as 'window' rather than as 'this'.

That would not be compatible with current Safari/WebKit behavior, and  
it may be a compatibility risk. I think anyone proposing this change  
should do research to determine the scope of the risk, and our default  
position should be "no compatibility-breaking changes until proven  
relatively safe".

Regards,
Maciej

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.mozilla.org/pipermail/es-discuss/attachments/20080915/9f0dccd7/attachment.html 


More information about the Es-discuss mailing list