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

remove arguments option in go #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jlongster
Copy link
Collaborator

I have a good proposal for error handling I think, but one thing that it does is gives you the ability to configure a go block to automatically propagate. I don't think we should add tons of options to go functions, but this is useful enough to merit it. It should look like:

go(function*() {
  // ....
}, { propagate: true });

Right now you'd always have to pass an empty array as the second argument. I've always found that argument redundant though since we have spawn. Either just use those variables directly in the go block, or use spawn to call the generator with the args, like spawn(gen(arg1, arg2)). In the rare case that you need to use this with a new function, just do spawn((function*(x, y, z) { ... })(x, y, z)).

Removing this gives us the ability to add the above option (which I will go into more details in the errors PR), without removing hardly any functionality. What do you think?

@nmn
Copy link
Contributor

nmn commented Jan 27, 2015

I like the way tj's co handles arguments:

go(function*(...args){
  //...
})(...args);

It's a little extra to type for simple go blocks, but it is actually very useful in many cases. It makes it easy to pass things around, etc.

As for composition, I think it makes a ton of sense that a go block should return a channel with the generator's final return value.

@jlongster
Copy link
Collaborator Author

What you're talking about I think is a different kind of function that doesn't immediately start the process, but returns a function that takes arguments and starts it with them. We can add something like that.

@nmn
Copy link
Contributor

nmn commented Jan 28, 2015

@jlongster Consider making that the default. As that would solve more cases that the current function.

Also, then we don't have to sacrifice arguments for the propagate option:

go(function*(...args) {
  // ....
}, { propagate: true })(...args);

@jlongster
Copy link
Collaborator Author

See my comment here: #15 (comment) Unfortunately I do not have time to contribute here.

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.

None yet

2 participants