Proposal: opt-out local scoping

Erik Arvidsson erik.arvidsson at gmail.com
Thu Aug 28 09:44:37 PDT 2008


I hope we can still have "global" in Harmony.  It is ugly to have to do:

const global = this;

and rely on that no one moves that code into a closure with a different "this".

Dave,  I really like the lexical scope proposal.  However,  I do find
the sections regarding the global a bit confusing.  Are the following
assumptions correct?

this.print = function(s) { ... };

{
  use lexical scope;
  this.print('OK');
  print('FAIL');
}

-- 
erik

On Thu, Aug 28, 2008 at 06:22, P T Withington <ptw at pobox.com> wrote:
> On 2008-08-28, at 09:09EDT, Dave Herman wrote:
>
>> As for free references, what can you do with a free variable? If you
>> mean you want a way to look something up in the global object, then
>> use `this.id' or `this[expr]' (or `let global = this' followed by
>> global.id/global[expr]).
>>
>> It might be nice to have a standard library (called `global' or
>> something) that's bound to the global object so you can have a less
>> fragile binding to the global object than `this'.
>
> Exactly.  I think it would be worthwhile to have a standard way to
> refer to the global object.
> _______________________________________________
> Es-discuss mailing list
> Es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>


More information about the Es-discuss mailing list