lexical for-in/for-of loose end

Grant Husbands esdiscuss at grant.x43.net
Sun Feb 5 03:55:21 PST 2012

Herby Vojčík wrote:
> I meant all that copying there and back and having two variables with the
> same name in two scopes and handling all combinations when to access which
> one. I wanted to take this away.

Yes, at least my desugaring was indeed overcomplicated. Brendan's and
Mark's desugarings aren't that complicated, though.

>> Your proposal depends on being able to reassign variable pointers, but
>> they don't necessarily exist.
> Well, references are all over the spec (or were in times of ES5).

What I was calling activation records, the spec calls environment
records and it does not, by my reading, imply that variables within
them are reference-like in nature (read clause 10.2). However, we
don't need to argue this point.

>> Or, here's one that copies the other way (and is probably cleaner):
>> 'Note' all closures (dynamically) created in (lexically,
>> post-desugaring) the loop body. Each time you end an iteration, update
>> all the loop variable activation record pointers to point at a new
>> clone of that activation record.
> If I understood correctly, this is what I proposed. Or maybe it only looks
> like it?

It has the same behaviour, but without needing variable pointers; that
was the idea. I now propose it to the list as a variant of your idea
that I think some may prefer. I'm merely trying to make sure your idea
gets the attention it deserves.

To be completely acceptable, the mechanics would need fleshing out, of course.


More information about the es-discuss mailing list