13.6.4.12 Runtime Semantics: ForIn/OfHeadEvaluation ( TDZnames, expr, iterationKind, labelSet)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

13.6.4.12 Runtime Semantics: ForIn/OfHeadEvaluation ( TDZnames, expr, iterationKind, labelSet)

Axel Rauschmayer

I don’t understand step 2: the temporary environment TDZ is created for step 3. All bindings of TDZ are mutable (even the `const`-declared ones). It looks like TDZ is thrown away afterwards. Why is this step necessary? Why are all bindings mutable?

Thanks!

Axel

-- 
Dr. Axel Rauschmayer
[hidden email]
rauschma.de


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: 13.6.4.12 Runtime Semantics: ForIn/OfHeadEvaluation ( TDZnames, expr,iterationKind, labelSet)

Allen Wirfs-Brock

It makes things like this:

 

let x=0;

for (let x of (x=2, obj) {...}

 

produce an error.

 

Essentially it is creating a TDZ for 'x' that spans the of expression. It doesn 't make a difference whether the TDZ binding for x is mutable or immutable because the binding is never initialized so any reference to it will produce an error. 

 

Allen

On Wed, 13 May 2015 15:41:36 +0200, Axel Rauschmayer <[hidden email]> wrote:

 
I don’t understand step 2: the temporary environment TDZ is created for step 3. All bindings of TDZ are mutable (even the `const`-declared ones). It looks like TDZ is thrown away afterwards. Why is this step necessary? Why are all bindings mutable

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss