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

greedy outputs #290

Merged
merged 2 commits into from
Nov 30, 2023
Merged

greedy outputs #290

merged 2 commits into from
Nov 30, 2023

Conversation

mbostock
Copy link
Member

Fixes #144 by avoiding pausing the generator in the first place. This changes the semantics such that a generator such as this is greedily evaluated, rather than being ignored unless it is referenced by another code block:

const i = (function* () {
  for (let i = 0; true; ++i) {
    yield i;
  }
})();

I think it’s good that declared generators are greedily evaluated, as it’s probably more expected, and makes it easier to do animation within a cell.

@mbostock mbostock requested a review from Fil November 30, 2023 21:44
@mbostock mbostock merged commit 289bce3 into main Nov 30, 2023
1 check passed
@mbostock mbostock deleted the mbostock/greedy-outputs branch November 30, 2023 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detached generators don’t resume when reattached
2 participants