A recurring topic. See:
https://mail.mozilla.org/pipermail/es-discuss/2007-March/003964.html
https://mail.mozilla.org/pipermail/es-discuss/2008-February/005314.html
https://mail.mozilla.org/pipermail/es-discuss/2008-July/006812.html
and probably many others.
There's no common semantics among top five browsers (although IIRC three follow
IE, the #2 by market share did something different long, long ago).
So for Harmony, we are reclaiming function in block (must be a direct child of
a braced block) to bind a block-local name on block entry (so hoisting lives,
but only to top of block -- so you can't emulate with var f = function ...).
/be
On Nov 11, 2010, at 3:46 PM, Michael Day wrote:
> Hi,
>
> In ECMAScript, function declarations are SourceElements, but not Statements.
> This means that they can only occur at the top level, and may not be nested
> inside a block.
>
> However, browsers support function declarations as statements, and many
> scripts on the web seem to make use of this ability, especially after they
> have been minified.
>
> Is there a spec anywhere for how functions as statements should behave?
>
> Can they be rewritten to var + function expression, so that this:
>
> {
> function f() { return 17 }
> }
>
> becomes this:
>
> {
> var f = function() { return 17 }
> }
>
> When implementing non-standard features, it would be nice to do so in a
> standard manner :)
>
> Best regards,
>
> Michael
>
> --
> Print XML with Prince!
> http://www.princexml.com
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss