Re: hoisting past catch

2010-11-04 Thread Peter van der Zee
Shouldn't any var declared in the catch block be locally scoped as well? It seems that all browsers ignore that. try {x} catch(){ var y; } alert(y); The above should throw an error, yet it's undefined. In fact, even if the catch is not thrown y still exists (but if the catch block is not

Re: hoisting past catch

2010-11-04 Thread Brendan Eich
On Nov 4, 2010, at 10:32 AM, Peter van der Zee wrote: Shouldn't any var declared in the catch block be locally scoped as well? var always hoists to top of function or program. Why would it be different in a catch block? It's not in ES3, which standardized try/catch/finally. It seems that

Re: hoisting past catch

2010-11-04 Thread Brendan Eich
On Nov 4, 2010, at 12:00 PM, Peter van der Zee wrote: I guess my confusion came from the notion that catch gets its own scope and thinking variables in catch statements wouldn't get hoisted until the code in that scope was entered. Thanks :) catch did prefigure let -- lexical scope in ES3

Re: hoisting past catch

2010-11-04 Thread Brendan Eich
On Nov 4, 2010, at 12:18 PM, Brendan Eich wrote: On Nov 4, 2010, at 12:00 PM, Peter van der Zee wrote: I guess my confusion came from the notion that catch gets its own scope and thinking variables in catch statements wouldn't get hoisted until the code in that scope was entered. Thanks :)

Re: hoisting past catch

2010-11-01 Thread Brendan Eich
On Oct 11, 2010, at 4:40 PM, David Herman wrote: ES3 `catch' is block-scoped. At the last face-to-face, we talked about statically disallowing var-declarations from hoisting past let-declarations: function f() { { let x = inner; { var x =

hoisting past catch

2010-10-11 Thread David Herman
ES3 `catch' is block-scoped. At the last face-to-face, we talked about statically disallowing var-declarations from hoisting past let-declarations: function f() { { let x = inner; { var x = outer; // error: redeclaration } }