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

Generator Functions #97

Open
BobVarioa opened this issue Jul 1, 2024 · 0 comments
Open

Generator Functions #97

BobVarioa opened this issue Jul 1, 2024 · 0 comments
Labels
A-codegen area: codegen C-ecma262 conformance: ecma262 (any) S-epic size: epic T-feature type: feature

Comments

@BobVarioa
Copy link
Contributor

BobVarioa commented Jul 1, 2024

This is likely incredibly far future, but I really only see one way to implement this with Porffor's current architecture, and without other proposals.

Passing in a program counter argument and having lots of tests for it, essentially implementing our own jump semantics

function* gen() {
 console.log("a");
 yield;
 console.log("b");
 return "done";
}
// =>
function gen(pc) {
  if (pc == 0) { console.log("a"); pc++ }
  if (pc == 1) { pc++; return [undefined, pc] }
  if (pc == 2) { console.log("b"); pc++; }
  if (pc == 3) {
    return ["done", pc];
  } 
}

The AssemblyScript developers have an open issue for it, but it seems like there hasn't been much progress there.

It does look like there's a relevant WASM proposal, but it doesn't have good engine support yet.

@CanadaHonk CanadaHonk added A-codegen area: codegen T-feature type: feature C-ecma262 conformance: ecma262 (any) S-epic size: epic labels Jul 1, 2024
This was referenced Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen area: codegen C-ecma262 conformance: ecma262 (any) S-epic size: epic T-feature type: feature
Projects
None yet
Development

No branches or pull requests

2 participants