return when desugaring to closures

Brendan Eich brendan at
Thu Aug 21 18:51:52 PDT 2008

On Aug 21, 2008, at 6:45 PM, David-Sarah Hopwood wrote:

> In your example below, the opt_* variables are globally scoped in the
> case where they are not affected by the 'with'. The global scoping is
> not fully lexical (and I fully agree with your dismissal of the global
> scope semantics as "hopeless"), but it isn't the 'with' construct that
> is causing that.

Wrap my example in a function and then what kind of scoping do you have?

> This is lexical scoping with conditional shadowing. If it were  
> dynamic, then
> you'd expect:
>    function setOptionB(x) {
>      print(x == opt_B);
>    }
>    setOptions({opt_B: 42});
> to print true, but it actually prints false.

I don't see how. Dynamic scope means the caller's environment is  
visible to the callee. But an object initialiser passed as an actual  
argument does not bind any of its properties in the caller's  

I've never heard of lexical scoping with conditional shadowing.  
Lexical scoping as I understand it means the binding environment can  
be judged statically (at compile time -- interesting contrast with  
dynamic typing, but one does find the two paired often). Is there a  
programming language of note with lexical scoping with conditional  


More information about the Es-discuss mailing list