Inner functions and outer 'this' (Re: That hash symbol)

David Herman dherman at mozilla.com
Tue Mar 29 07:28:13 PDT 2011


On Mar 29, 2011, at 7:26 AM, David Herman wrote:

> This is what Sam is referring to -- we've been talking about exactly such a feature.

Sorry if that wasn't clear: at the last face-to-face we talked about allowing you to give your own custom name for the |this|-parameter, so that you could continue to refer to outer-bound |this|. This would use good ol' lexical scope, instead of exotic scope-crawling indices.

Dave

> I continue to believe that something like the ^this feature we've been talking about is as likely to introduce bugs as it is to fix bugs. It's like special language support for off-by-one errors.
> 
> Dave
> 
> PS A propos of nothing, the ^this syntax probably doesn't work because of ASI; try parsing:
> 
>    x = y
>    ^this.foo()
> 
> On Mar 29, 2011, at 6:47 AM, P T Withington wrote:
> 
>> On 2011-03-29, at 08:52, Sam Tobin-Hochstadt wrote:
>> 
>>> I agree entirely that it goes with the existing fixed implicit |this|
>>> binding -- I just think that cuts the other way.  The reason we're
>>> having this discussion is that the existing behavior of |this| isn't
>>> always what you want, and is hard to get around because of its fixed
>>> and implicit nature.  I think we should alleviate *that* problem, not
>>> just the worst symptom.
>> 
>> Way back in
>> 
>> https://mail.mozilla.org/pipermail/es-discuss/2008-August/007273.html
>> 
>> I raised the `this` problem:  When you write a function you can choose the names of all your parameters (for maximum legibility of your code) except the implicit one, where you are forced to accept the name `this`.  If you could specify a different name, specifying which implicit binding you meant in the presence of multiples would be simplified.
>> 
>> I won't propose a syntax for specifying an alternative name for `this`, for fear of being taken out to the (bike)shed and getting caned, but I do think it worth considering:  why must that implicit parameter have a fixed name?
>> 
>> 
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss



More information about the es-discuss mailing list