On May 14, 2012, at 2:44 PM, Claus Reinke wrote:
> 
>> Because let is a new feature, this restriction doesn't introduce any
>> backwards compatibility issues. However, for consistency, the draft
>> also currently applies the same let declaration restrictions to catch
>> parameters.
> 
> Even better!-) And in line with treating catch as an anonymous function.

An analogy with inner functions isn't needed and wouldn't be correct.  This is 
simply appling the static semantics of Block level declarations. A Block  is 
not allowed to var declare (including via nested blocks) any identifier that is 
lexically declared in the block (but not including nested blocks).

function f() {
   try { throw "hi"
   } catch (e)  {
      var v;
   };
}

is legal and binds "v" at the top-level of function f.  If the catch clause was 
treated like an anonymous function, "v" would be bound at the level of the 
catch clause.  It isn't...

In terms of scope contours the above is equivalent to 

function f() {
  {  //throw "hi"
     }
  {
      let e;
      var v;
   }
}

Allen




_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to