Implementation of "smart enums" #9263
Unanswered
moon3legro
asked this question in
Language Ideas
Replies: 2 comments 7 replies
-
Syntax is the least significant point for designing such type system, and often decided in very late stage. Instead, we are focusing on what semantics we want to achieve. |
Beta Was this translation helpful? Give feedback.
5 replies
-
At this point I think the effort should be focused on discriminated unions since they cover a superset of use cases. A singleton case in a DU is basically the same as a "smart enum" case, and should both be a data carrier as well as support implementation and members. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have always seen and thought about quote-unquote "java enums are better than c# enums". After doing a bit of research I partially agree, but I quite like the simplicity of c# enums. So instead, I thought of some ideas on how to implement "smart enums" and be able to use the old simplicity of enums without breaking old projects while being able to use more complex enums if users wish. Here is my proposed syntax: (Note: the proposed semantics and syntax have been changed, please scroll down further)
Note: I have read #5937, but mine proposes a different syntax that doesn't break some old projects. As another example of the syntax:
UPDATE: I have changed my proposed semantics and my proposed syntax.
If you don't understand feel free to ask some questions!
Beta Was this translation helpful? Give feedback.
All reactions