Proposal: opt-out local scoping

P T Withington ptw at pobox.com
Thu Aug 28 13:23:58 PDT 2008


On 2008-08-28, at 15:47EDT, Brendan Eich wrote:

> Indeed, Doug Crockford proposed at the January TC39 meeting this  
> year to make 'this' act like a lexically bound variable, with the  
> only magic to it applying to the case of obj.method() call  
> expressions (and variatons, obj[name] where name = 'method'), where  
> 'this' would be overridden -- if you will, a shadowing 'this' would  
> be bound to obj.
>
> I liked Doug's proposal quite a bit. I do not see anything like it  
> in ES3.1, but I'd like to see it in Harmony.

I'd like to know more about the proposal, since I can't figure out  
what "make 'this' act like a lexically bound variable" means.

I'd like to have a syntax where this is _not_ implicitly bound.  One  
idea would be to riff on default arguments:

   function example (receiver=this, ...

to rename the implicit -1th argument to function calls.


More information about the Es-discuss mailing list