Replies: 11 comments 3 replies
-
Check out the conversation about this on the Roslyn repo: Of specific interest might be that Oracle owns a patent on Java's implementation of enums, so Microsoft would not be able to implement the same construct in C#: |
Beta Was this translation helpful? Give feedback.
-
@elcergey - I disagree that Java has a "full fledged enum". Technically Java has a special kind of static class with special interface characteristics that the language designer chose to refer to as an enum. Just because the Java team called this an enum doesn't mean that this somehow redefines the meaning of "enum". C, C++ and Pascal support enums and enumerated types that are pretty much the same as we have in C#. It might be a good idea to give C# something similar but I would not advocate changing the definition of enum but rather introduce a new term or express the concept using existing terms but perhaps in a new way. |
Beta Was this translation helpful? Give feedback.
-
That's totally sick. |
Beta Was this translation helpful? Give feedback.
-
I'm not sure I'm sad about this. |
Beta Was this translation helpful? Give feedback.
-
One example of a thing should have been an enum and instead is a struct is System.Drawing.Color that needing to have methods (for example the one that converts the color to an ARGB int) and properties (A, R, G, B for example) needed to be a stuct with a "complex" system to construct a new Color starting from "KnowColors". Maybe adding the possibility to add extensions methods to enum could in part solve the issue but code it like a class / struct would be perfect but how to do this without infringe Oracle copyright? |
Beta Was this translation helpful? Give feedback.
-
I think dotnet/roslyn#3704 is not under that patent (or is it?). |
Beta Was this translation helpful? Give feedback.
-
@alrz Two years have passed since then, still nothing. |
Beta Was this translation helpful? Give feedback.
-
Probably not. If we were going down this path I'd rather pursue similar functionality to Apple Swift's enums, which also gets us some nice syntax for closed ADTs. @elcergey You can only eat an elephant one bite at a time. |
Beta Was this translation helpful? Give feedback.
-
Might related #144 |
Beta Was this translation helpful? Give feedback.
-
Good syntax for this is |
Beta Was this translation helpful? Give feedback.
-
Oracle's enum patent expires at the beginning of 2024. So new |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
As is known, Java has full-fludged enums (with constructors, methods). Why not add that to C# ?
Of course, we can always declare a new class to simulate enums but this feature would render that reduntant.
Beta Was this translation helpful? Give feedback.
All reactions