winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
4.92k stars 194 forks source link

Syntactic sugar for contextual enum values #4323

Open eladb opened 11 months ago

eladb commented 11 months ago

Feature Spec

Wherever an enum value is expected in Wing code (e.g. as the first argument of the foo function or the bar variable):

enum MyEnum {
  MY_MEMBER,
  YOUR_MEMBER,
}

let foo = (e: MyEnum) => {};
let bar: e: MyEnum;

You can either use the fully qualified member name:

foo(MyEnum.MY_MEMBER);

if bar == MyEnum.YOUR_MEMBER {
  // ...
}

Or you can use a sugar notation:

foo(.MY_MEMBER)

if bar == .YOUR_MEMBER { ... }

Inspired from Swift.

Use Cases

Make it easier to reference a member enum in context.

Implementation Notes

No response

Component

Language Design, Compiler

Community Notes

github-actions[bot] commented 9 months ago

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[bot] commented 7 months ago

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[bot] commented 4 months ago

Hi,

This issue hasn't seen activity in 90 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[bot] commented 1 month ago

Hi,

This issue hasn't seen activity in 90 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!