On Sat, Oct 11, 2008 at 8:35 PM, David-Sarah Hopwood
<[EMAIL PROTECTED]> wrote:
> The reason for making 'const' hoist to the top of the enclosing block,
> AFAIR, was consistency with function declarations. However, there are
> good reasons why 'const'/'let' and function declarations should be
> treated differently:
The following issue invalidates one of your reasons.
{
.... f(); ...
const x = 3;
function f() { ... x ... }
}
Since functions hoist, if const do not, then in the example above, either
1) we must not allow f to refer to x, or
2) we must still have a read barrier, since f may still be invoked and
access x before x is initialized.
I hope we can agree that #1 is unacceptable. Thus, whether const or
let hoists or not, we must still deal with the same use-before-init
issues.
--
Cheers,
--MarkM
_______________________________________________
Es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss