-
Notifications
You must be signed in to change notification settings - Fork 156
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
Promise Generators #752
Comments
I was reading around the issues and came across #683 and I'm wondering if it would make more sense to implement this as await/async. I wasn't aware that ES7 had a spec for this. I could keep the syntax the same, but add a new keyword |
I went ahead and did the async/await approach in another branch. The changes can been seen here: https://github.com/kkirby/LiveScript/tree/async-await. I realize that async can be considered an ident in other contexts, but as of now, I haven't solved that issue. I thought I did, but I forgot about the possibility of parameters, and my solution wasn't exactly pretty. Example:
Result:
|
|
@zloirock So you're thinking LiveScript should handle the transpilation of the syntax sugar itself? |
@kkirby I just think LiveScript async functions should be equal ES7 async functions and they should not break CSP. |
@zloirock Ohhh. Okay, sorry. Gotcha. I wasn't sure what you meant by CSP. The options were communicating sequential processes or content security policy. I had figured you meant the former since we were talking about async io. Anyways, if I am understanding you correctly, you're saying that because I'm using If that's the case, then yes, that's a much better idea. However, since I may end up going the route of just adding in the async/await keywords into LiveScript, it removes the need for the generatorToPromise helper all together. |
@kkirby content security policy disallow any form of |
@zloirock Thanks for the guidance. I've updated my generator-promise branch to use the |
I'd like to get a discussion going, but we're not going to do the transpiling ourselves. What syntax should we chose? |
Hello.
I have updated LiveScript in a fork to support promise generators. The syntax looks like this:
The compiled code renders as such:
My only big concern is using this along with currying. The issue is that currying requires knowing the arguments length of the function, but since all functions are being wrapped, the argument length would be zero. To work around this, I have opted to pass in the argument length if the function is curried and create a function via a string. It's pretty gross, but I can't immediately think of a better way that works across platforms.
You can check the fork out here: https://github.com/kkirby/LiveScript/tree/generator-promise
If promise generators are desired, but modifications are requested, I'm open for discussion. Otherwise, is this something that could become a part of LiveScript?
The text was updated successfully, but these errors were encountered: