hoisting past catch
brendan at mozilla.com
Thu Nov 4 12:22:38 PDT 2010
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 :)
> catch did prefigure let -- lexical scope in ES3 from 1999, but only for catch. Finally we get it everywhere in Harmon, at the price of new syntax.
I'm being too kind to ES3. It aspired to make the catch var lexical and block-scoped, but it was terribly specified: it used a new Object for the scope frame, and bound the catch variable via [[Put]], if I recall correctly. Fixed in real world implementations to avoid object-based scoping, and codified in ES5.
More information about the es-discuss