April 10 2014 Meeting Notes
Allen Wirfs-Brock
allen at wirfs-brock.com
Thu Apr 24 12:57:04 PDT 2014
On Apr 24, 2014, at 12:16 PM, Brendan Eich wrote:
> Jason Orendorff wrote:
>> OnThu, Apr 24, 2014 at 1:38 PM, Allen Wirfs-Brock
>> <allen at wirfs-brock.com> wrote:
>>> > [...]What we did take seriously was the concern about not running generator finally blocks when a for-of initiated generator has an early exit. We don't need to redefine @@iterator conventions to address that issue.
>>
>> This reminds me --- "for-of initiated" here refers all the places
>> where the spec uses IteratorStep etc., right? Things like the spread
>> operator, destructuring assignment, and Array.from, for example?
>>
>> That is, we're talking about a protocol change, not a narrow change to
>> for-of evaluation. Right?
>
> No one is talking seriously about such a change.
This was always a consideration that I was aware of in this discussion and I assume that I would have to review all the spec. level uses of IteratorStep. The issue arises whenever there is a exist condition from the iterator draining loop that can be trigger outside of the iterator's logic.
For example, if think I would expect this:
lines = Array.from(LineReader("file/path"), line => {if (line==="***eval***) throw "evil exists in file" else return line});
to cleanup it open file descriptor, if this did:
for (line of LineReader("file/path"),{ine => {
if (line==="***eval***) throw "evil exists in file";
}
>
> The only proposal (let's table whether the name is 'return' or @@return) is whether for-of constructs should have a finally maybe-call of the iterator's return method, if present. Like SpiderMonkey's JS1.7-1.8 close method, based in part on Python 2.5 and up.
>
Really, the only reason we even considered this at the TC39 meeting was because we believed it was a fix it now, or never situation. I'm now less convinced that this is the situation. If we shipped ES6 as is and later added @@return and the finally maybe-call within for-of, is anybody going to be unhappy or broken? It would only really impact any generators that have finally cleanups and and which are used in for-of loops with early terminations.
Allen
More information about the es-discuss
mailing list