On Jul 9, 2008, at 5:16 PM, Allen Wirfs-Brock wrote:
Const and function declarations within blocks must be uniquely
named, such a declaration may not over-write a preceding declaration
in the same block and an attempt to do so is a syntax error. Such
declarations, of course, shadow any like named declarations in
enclosing scopes. Since consts and function declarations in blocks
are new, this is a new semantics.
Although the standard does not allow block-level function
declarations, the following will parse and give identical results in
all four of the major browsers (it will alert "2"):
<script>
function g() {
if (true) {
function f() { alert("1"); }
function f() { alert("2"); }
}
f();
}
g();
</script>
This example will interoperably alert "1":
<script>
function g() {
if (true) {
function f() { alert("1"); }
}
f();
}
g();
</script>
As I understand it, your proposal would make the first example a
syntax error and the second a runtime error (unless a global function
named f is defined).
I know from experience that sites do accidentally depend on the
intersection of the different IE and Firefox extensions for block-
level function declarations (and the Safari and Opera attempts to
emulate them). Do you have evidence that leads you to conclude that
your proposed behavior is compatible with the Web? I am almost certain
it is not.
Regards,
Maciej
_______________________________________________
Es4-discuss mailing list
Es4-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es4-discuss