frozen v. mutable
Lars Hansen
lhansen at adobe.com
Tue Jun 17 08:53:31 PDT 2008
> -----Original Message-----
> From: es4-discuss-bounces at mozilla.org
> [mailto:es4-discuss-bounces at mozilla.org] On Behalf Of Brendan Eich
> Sent: 17. juni 2008 17:26
> To: Mark S. Miller; Waldemar Horwat
> Cc: es4-discuss at mozilla.org es4-discuss;
> es3.x-discuss at mozilla.org x-discuss
> Subject: Re: frozen v. mutable
>
>
> > IIUC, our
> > meaning for it is exactly the meaning in ES4: the variable is
> > letrec-scoped to its containing block (as with ES4 "let") but the
> > variable is also unassignable. The variable declaration must provide
> > an initial value. An assignment to a const variable causes the
program
> > to be statically rejected. The variable is initialized when its
> > initializing declaration is executed. (i.e., unlike functions, a
const
> > variable's initialization is not hoisted to the beginning of its
> > block.) Any attempt to read the variable before it is initialized
> > fails. In strict mode this failure is a throw. In non-strict mode,
the
> > failure is the reading of undefined.
>
> Did we agree to allow undefined be read before the
> declaration was evaluated? I thought at least Waldemar wanted
> const use before def always to be an error, in standard as
> well as strict mode.
That is indeed the current ES4 design; reading before initialization
always causes an error to be signalled. Ditto for 'let'. And of
course const properties are write-once, there's no need to initialize
it in the definition.
--lars
More information about the Es4-discuss
mailing list