Real World Func Decl in Block Scope Breakages
brandon at brandonbenvie.com
Wed Dec 26 18:04:44 PST 2012
My tests basically indicate what you said, but with a minor distinction.
They don't fail outright, as in throw an error. They just fail silently. As
in, it's ok to call the identifier, but it's not going to do anything. This
is a curious Schrodinger's cat kind of intermediate state, where it doesn't
succeed in doing what it was asked, but doesn't throw an error either,
which in JS terms means it air-quotes succeeded but didn't really.
On Wed, Dec 26, 2012 at 9:02 PM, Brendan Eich <brendan at mozilla.com> wrote:
> Brandon Benvie wrote:
>> Unless I'm mistaken on how Spidermonkey handles function declarations in
>> block scope, almost none of those examples will work correctly in Firefox.
>> Most of them will work in every other major browser, but not in Firefox.
> No, that's not so. The ancient (pre-ES3) SpiderMonkey function-in-block
> semantics are like an assignment expression in effect, so if control flow
> reaches the nested function declaration, the var-like binding will be
> *created* and initialized. If control flow does not reach one of N possible
> for a given name, then the var-like binding won't even exist.
> Crazy but true.
> The snippets Brian posted all look like they'll work in SpiderMonkey /
> Firefox, at a glance from me. Let me know if I missed something.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss