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

Could there be better syntax for await? #10

Open
dimaqq opened this issue Oct 9, 2020 · 2 comments
Open

Could there be better syntax for await? #10

dimaqq opened this issue Oct 9, 2020 · 2 comments

Comments

@dimaqq
Copy link

dimaqq commented Oct 9, 2020

I feel that current syntax for await is counter-intuitive, it appears to invert the order of await and function call.

Could it be something more like:

const user = url
  |> await api.get
  |> r => await r.json()
  |> j => j.data.user;
@mAAdhaTTah
Copy link
Collaborator

I'm open to be better alternatives, but both of those examples have issues. url |> await api.get is ambiguous between await apt.get(url) or (await apt.get)(url). The latter is impossible because the arrow function itself becomes the new async context, rather than the context the pipeline is in (if that makes sense).

@dustinlacewell
Copy link

dustinlacewell commented Apr 7, 2021

I would think that x |> await y would always desugar to await (y(x)) if await appears as the first token of the RHS.

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

No branches or pull requests

3 participants