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

Add yield support #3073

Closed
gunta opened this issue Jul 19, 2013 · 30 comments
Closed

Add yield support #3073

gunta opened this issue Jul 19, 2013 · 30 comments

Comments

@gunta
Copy link

gunta commented Jul 19, 2013

I know that the policy was not new adding new ES6 features.

But now, it's 2013,
and the latest V8 and Node.js 0.12 supports yield,
which is one of the best features to prevent callback hell.

We should add support for it, because it really improves the current situation of callbacks spaghetti in Node.js.

Thank you.

@michaelficarra
Copy link
Collaborator

+1. I've been meaning to open an issue for support of all ES6 features. It raises the question of whether we want to adopt the ES6 syntax/semantics for features that we've introduced separately, for example list comprehensions and super. But no such problems exist with adding yield. I'd prefer to wait until the final draft of ES6 has been released, still, before including any of its features. That and I wouldn't want to include them in a 1.x version of the compiler.

@gunta
Copy link
Author

gunta commented Jul 19, 2013

What about having a --harmony flag?

It would follow the Node.js and V8 practices,
and it makes sense because people writing code for Node.js usually want to try latest features because the code is not tied to old browsers.

@michaelficarra
Copy link
Collaborator

What do we do when ES6 is finalised and we want to make these features official? Have --harmony be a meaningless flag?

@gunta
Copy link
Author

gunta commented Jul 19, 2013

It is going to take some years to be outdated so I don't think it's meaningless and neither does the V8 and Node.js team.

Because it is the only way to test forward the advance in JavaScript.
After all, after the ES6 spec is finished, there will be also ES7 and ES8.

@michaelficarra
Copy link
Collaborator

@jashkenas: I'd really like to get your input on this, especially my first comment above. I feel pretty strongly that CoffeeScript needs to evolve or die, and also prefer that it remain a simple enhancement over what you can do with the latest version of ECMAScript (sans anti-features like with and getters/setters of course). This doesn't necessarily mean dropping our ES3 compilation target. We should be

That last point's going to be tough. I don't want a separate ES3-target, ES5-target, and ES6-target compiler, and I'm sure you don't either. I think we should consider a flag like the suggested --harmony to allow usage ("pass-through") of ES6 features that we can't support with an ES3 target.

@jashkenas
Copy link
Owner

Agreed. I think that we should start considering the new features as soon as they begin to work in browsers, and on Node.

Ideally, it'll continue to be a single target compiler, and your output JS will simply be ES3-incompatible if you use ES3-incompatible features (as it already is if you [].map(), for example). Features that aren't backwards compatible need to be clearly documented on the homepage.

I think that evaluating and implementing these things as they arrive, is a fine way to get started. Yield is probably a good one to begin with.

@michaelficarra
Copy link
Collaborator

Just to be clear, that means you also support the syntactic and semantic changes needed to bring CS in line with ES6? Should I reopen #2638 and #1340?

edit: Also, this should obviously wait until 2.0 or replacing this compiler with CSR.

@jashkenas
Copy link
Owner

that means you also support the syntactic and semantic changes needed to bring CS in line with ES6

No, not necessarily. Just like CoffeeScript's semantics don't perfectly match ES3's. I think that our current super is nicer than ES6's, by a long shot ... and I think that for loops should continue to be meaningful expressions as maps and filters, if you use them as such.

Regardless, classes, super, and comprehensions aren't shipping in V8 just yet, are they? Aren't they still in flux?

@aaronshaf
Copy link

"Agreed. I think that we should start considering the new features as soon as they begin to work in browsers, and on Node."

This is really encouraging!

@EndangeredMassa
Copy link

I've gone back and forth on this in my head. I think that the Ideal CoffeeScript is one that targets ES6 (with CS syntax and minimal semantic updates) and compiles to ES3 or ES5. However, I don't think that changing some things like super and comprehensions is a great idea at this point.

So, I agree with the progressive approach. Starting with yield/generators sounds perfect because it's already being used in several interesting libraries.

@monolithed
Copy link

+1

@sircambridge
Copy link

+1 yield pretty please

@helmus
Copy link

helmus commented Nov 7, 2013

+1 !

@Artazor
Copy link
Contributor

Artazor commented Nov 14, 2013

+1 for yield

@fheisler
Copy link

+1, please yield!

@stephenhandley
Copy link

+1 yield

@vendethiel
Copy link
Collaborator

We have a PR for that

@xixixao
Copy link
Contributor

xixixao commented Jan 20, 2014

#3240

@let4be
Copy link

let4be commented Jul 12, 2014

@socketpair
Copy link

I did not understand, is yield supported or not now.

@monolithed
Copy link

You do not understand.
We have the operator %%, which is much more important and useful 😜

🐎

@socketpair
Copy link

@monolithed, your joke is not relevant. Please write on the case.

И таки да, шутку не оценил, лучше бы про yield сказал по делу.

@monolithed
Copy link

@socketpair, try ES6

@bjmiller
Copy link

Generator support now exists on master, and will go out with the next major release.

(Unless I'm missing something?)

@let4be
Copy link

let4be commented Jan 26, 2015

You are missing ES6, why would you need to use outdated coffee when you can
use ES6 generators with traceur or 6to5? ;)
classes, modules, arrow function and many else

2015-01-26 17:04 GMT+03:00 Brian Miller notifications@github.com:

Generator support now exists on master, and will go out with the next
major release.

(Unless I'm missing something?)


Reply to this email directly or view it on GitHub
#3073 (comment)
.

@bjmiller
Copy link

#3162 (comment)

@MattKunze
Copy link

Bummer, seems like there's no support for yield* - we've started using redux-saga and it's been working great, but just came across a case where yield* made things a lot simpler and had to escape it with backticks.

@lydell
Copy link
Collaborator

lydell commented Jul 15, 2016

@MattKunze yield* is called yield from in CoffeeScript.

@MattKunze
Copy link

Awesome, thanks! Somehow missed that in the docs

@foxbunny
Copy link

Agreed. I think that we should start considering the new features as soon as they begin to work in browsers, and on Node.

@jashkenas Do you think it would be unreasonable to target Babel and similar with CS output, rather than the 'bare-metal' runtimes? Cause that's kinda what I was contemplating. :)

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