4 ms·
Hmm, it looks interesting but it seems to lack a precise need that's not covered atm imo. I also wonder how defer would be handled. After the last yield? After
by c0balt 3y ago
Hmm, it looks interesting but it seems to lack a precise need that's not covered atm imo.
I also wonder how defer would be handled. After the last yield? After each yield? Should defer be executed when an iterator is not fully consumed?
- _0w8t 3y agoDefer will be executed normally when the function exits. yield here is not a statement but a normal function.
- _0w8t 3y agoI.e. C# and many other languages transform a function with the yield statement into a state machine implementing the iteration protocol. This proposal does the opposite. It transforms the loop body into a closure passed into the iterator.