const initializers: once more unto the breach

Andy Wingo wingo at igalia.com
Tue Mar 20 08:55:51 PDT 2012


On Tue 20 Mar 2012 16:45, Andy Wingo <wingo at igalia.com> writes:

> Unifying the specifications of let and const in the latest draft means
> that now, const statements can have no initializer.  Is that intended?

Of course, after sending this mail, I find:

    Static Semantics: Early Errors
    LexicalBinding : BindingIdentifier

    It is a Syntax Error if the BindingIdentifier if IsConstantDeclaration of the LexicalDeclaration containing
    this production is true.

Some of the const strangeness is still there though.  It's not
necessarily the case that the value of the const is either nothing (in
which case you get a TDZ error) or the result of the initializer --
anything else that executes before the const could set it.

So a revised ignorant suggestion on my part:

> disallow assignment to const variables outside an initializer

Regards,

Andy
-- 
http://wingolog.org/


More information about the es-discuss mailing list