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

Function Types: Promise #1004

Open
eladb opened this issue Dec 29, 2022 · 6 comments
Open

Function Types: Promise #1004

eladb opened this issue Dec 29, 2022 · 6 comments
Labels
🛠️ compiler Compiler ✨ enhancement New feature or request 📜 lang-spec-impl Appears in the language spec roadmap roadmap

Comments

@eladb
Copy link
Contributor

eladb commented Dec 29, 2022

Feature Spec

https://github.com/winglang/wing/blob/main/docs/04-reference/winglang-spec.md?rgh-link-date=2022-11-10T13%3A18%3A56Z#362-promises

Support for Promise.xxx use cases.
It is now possible to implement advanced concurrency flows using the promise API:

These statements behave like their JavaScript Promise.xxx counterparts.

  1. Promise.all(p1, p2, ...)
  2. Promise.any(p1, p2, ...)
  3. Promise.all_settled(p1, p2, ...)
  4. Promise.race(p1, p2, ...)

The result is a promise that needs to be explicitly awaited.

For example, let's say I want to wait for two async operations to succeed before continuing the flow:

let p1 = defer async1();
let p2 = defer async2();
await Promise.all(p1, p2);

In this suggestion, the Promise type is similar to other built-in types like Set, Map, ...

Use Cases

Advanced concurrency

Implementation Notes

No response

Component

Compiler

@eladb eladb added the ✨ enhancement New feature or request label Dec 29, 2022
@monadabot monadabot added this to Wing Dec 29, 2022
@github-project-automation github-project-automation bot moved this to 🆕 New - not properly defined in Wing Dec 29, 2022
@Chriscbr
Copy link
Contributor

Chriscbr commented Jan 2, 2023

Should promise be the name of some global object, or should it require bring promise;?

(I'm guessing we should minimize global namespace pollution in our language if possible)

@ShaiBer
Copy link
Contributor

ShaiBer commented Jan 2, 2023

I agree that we should minimize, but think promise should be there

@eladb
Copy link
Contributor Author

eladb commented Jan 2, 2023

We should consider various syntax options.

I actually think the JS syntax is pretty solid, so it could be just Promise.xxx() (same as we have Array and Set..,

@eladb
Copy link
Contributor Author

eladb commented Jan 2, 2023

Updated the description to use capital letter

@staycoolcall911 staycoolcall911 changed the title Support for Promise.xxx use cases Function Types: Promise Jan 3, 2023
@staycoolcall911 staycoolcall911 added 📜 lang-spec-impl Appears in the language spec roadmap 🛠️ compiler Compiler labels Jan 3, 2023
@staycoolcall911 staycoolcall911 moved this from 🆕 New - not properly defined to 🤝 Backlog - handoff to owners in Wing Jan 3, 2023
@staycoolcall911 staycoolcall911 moved this from Todo to Todo - out of scope for beta in Wing Language Roadmap Jan 26, 2023
@github-actions
Copy link

github-actions bot commented Mar 5, 2023

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!

@github-actions
Copy link

github-actions bot commented May 5, 2023

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🛠️ compiler Compiler ✨ enhancement New feature or request 📜 lang-spec-impl Appears in the language spec roadmap roadmap
Projects
Status: 🤝 Backlog - handoff to owners
Status: Todo - out of scope for beta
Development

No branches or pull requests

4 participants