Grant Husbands wrote:
Herby Vojčík wrote:
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.
I feel like misunderstood. I _know_ there aren't ref variables in the
spec. I never told that. I was just telling that 'i' inside the loop
body may be compiled not as "Ref(loop-body-record, 'i')" whenever it is
accessed/modified (and optimized when Ref is not really needed, but you
can see at it as if it is always Ref to local i), but as
"Ref(the-record-to-use, 'i')", the-record-to-use being local variable in
loop iteration which can change its value (it can be outer-record when
loop runs, at it can be local-record when iteration ends and values are
fixed in local 'i').
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.
Thanks. Yes it is the same behaviour, the active loop body always uses
the same shared 'i', only async closures get the fixed copy. Nice.
To be completely acceptable, the mechanics would need fleshing out, of course.
Regards,
Grant.
Herby
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss