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

Generators #68

Open
alongubkin opened this issue Nov 25, 2014 · 4 comments
Open

Generators #68

alongubkin opened this issue Nov 25, 2014 · 4 comments
Assignees
Milestone

Comments

@alongubkin
Copy link
Owner

Add generators support to Spider.

fn inorder(node) {
  if (node) {
    yield* inorder(node.left);
    yield t.label;
    yield* inorder(node.right);
  }
}

compiles to:

function* inorder(node) {
  if (node) {
    yield* inorder(node.left);
    yield node.label;
    yield* inorder(node.right);
  }
}

Note that * is not required near the Spider function declaration.

If you have a better idea for the yield* syntax, please let me know.

@alongubkin alongubkin self-assigned this Nov 25, 2014
@alongubkin alongubkin modified the milestones: 0.0.7-alpha, 0.1.2, 0.1.1 Nov 25, 2014
@Namek
Copy link
Collaborator

Namek commented Nov 30, 2014

Seeing this I dream about having lazy evaluation (for variables).

@nmn
Copy link

nmn commented Dec 1, 2014

This would be a big big win. Also, considering the fact that Spider already supports async functions, its surprising that generators aren't supported yet.

@Deveritas
Copy link

 If you have a better idea for the yield* syntax, please let me know.

Some possible keyword ideas: delegate, enter, use...
Of course, this is completely leaving out the question of whether a keyword is better than syntax in this case.

@nmn
Copy link

nmn commented Dec 14, 2014

I think the yield* syntax is fine. It makes sense, and is consistent.
Also, there is no obvious better syntax here...

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

4 participants