-
Notifications
You must be signed in to change notification settings - Fork 155
Closed
Labels
Description
I was using co library when I discovered that yielding comprehensions produces yield* expression just after regular yield but only when comprehensions were yielded directly (without temp variable)
Thouse work as expected:
with temp variable
!->*
temp = [i**2 for i til 10 ]
yield temp(function*(){
var y, res$, i$, i;
res$ = [];
for (i$ = 0; i$ < 10; ++i$) {
i = i$;
res$.push(Math.pow(i, 2));
}
y = res$;
(yield y);
});with hidden temp varible using ..
!->* [i**2 for i til 10 ]
yield ..(function*(){
var x$, res$, i$, i;
res$ = [];
for (i$ = 0; i$ < 10; ++i$) {
i = i$;
res$.push(Math.pow(i, 2));
}
x$ = res$;
(yield x$);
});And this doesn't:
!->* yield [i**2 for i til 10 ](function*(){
var i;
(yield (yield* (function*(){
var i$, results$ = [];
for (i$ = 0; i$ < 10; ++i$) {
i = i$;
results$.push(Math.pow(i, 2));
}
return results$;
}())));
});The same goes for object comprehensions.