A bit confused by B.3.2 - Web Legacy Compatibility for Block-Level Function Declarations
John Lenz
concavelenz at gmail.com
Fri Jun 6 18:30:30 PDT 2014
Great thanks for the links. I missed or had forgotten the Jan 2014
summary. The summary for that discussion is pretty clear that the
functions have two bindings (a block local one and a function scope one, if
it can) and I assume that is what the spec is trying to specify.
Specifically, within the block the function is locally bound so case like:
for (let x = 0;x<10;x++) {
function f() {return x};
storeF(function() {return f});
}
will work with block semantics, but references like:
if (x) {
function f() { return 1 }
} else {
function f() { return 2 }
}
f();
will still "work" (for some definition of "work"). I had previously
thought it was "either or". There is still a sharp edge but not one that
will break folks trying to use block scoped function declarations.
This seems like a pretty good compromise.
Or a link to the discussion that led to the content of this section?
There have been multiple discussions on this topic, on both es-discuss and
during TC39 meetings, so it's hard to point to a single discussion. For
example:
http://esdiscuss.org/topic/real-world-func-decl-in-block-scope-breakages
http://esdiscuss.org/topic/functions-as-blocks
https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-01/jan-29.md#function-in-blocks-in-non-strict-mode
On Thu, Jun 5, 2014 at 9:51 AM, John Lenz <concavelenz at gmail.com
<https://mail.mozilla.org/listinfo/es-discuss>> wrote:
>* Is there any place that has some concrete examples of the different cases
*>* we are trying support with this section (and whether the function is block
*>* scoped or not in each case)?*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140606/b864a0c9/attachment.html>
More information about the es-discuss
mailing list