Real World Func Decl in Block Scope Breakages

Brendan Eich brendan at mozilla.com
Fri Dec 28 00:08:29 PST 2012


Brendan Eich wrote:
>>
>> What is the proposed change?
>
> ES6 proposes that f-i-b always bind bar in the nearest enclosing 
> curly-braced block, hoisted in the manner of function in JS today but 
> to block scope, not function or program scope, so that the function 
> can be used in expressions evaluated before control flows to evaluate 
> the declaration of bar.
>
> This means the example can fail if !cond.

Argh, meant to write "even if (cond)" -- i.e. the example *will* fail 
because the call to bar() after then if-then cannot possibly call the 
inner bar defined in the "then" bllock, in the ES6-proposed semantics.

> Only within the "then" block (anywhere, thanks to hoisting) could one 
> safely use bar to mean the function declared within that block.

I got this sentence right :-|.

HTH,

/be


More information about the es-discuss mailing list