Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directly yielding comprehensions produces unnesesary yield* expresion. #938

Closed
bartosz-m opened this issue Nov 8, 2016 · 1 comment
Closed

Comments

@bartosz-m
Copy link
Contributor

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.

@summivox
Copy link
Contributor

#764

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants