[Proposal]: abstract enumerations #4545
Unanswered
Youssef1313
asked this question in
Language Ideas
Replies: 1 comment
-
The proposal didn't make much sense when I tried to write a full sample. There is something missing for this to become useful. @333fred I think it should be moved to a discussion in case someone can come up with a more formal, well-written one. |
Beta Was this translation helpful? Give feedback.
0 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.
-
abstract enumerations
Summary
Allows for multiple enumerations to share common members.
Motivation
(excuse me for the example being very specific to Roslyn codebase)
This reduces extra clutter when enumerations are supposed to share common members (as an example, CodeAnalysis.CSharp.SyntaxKind and CodeAnalysis.VisualBasic.SyntaxKind). The current way to do things is to have a base class with abstract method, for example,
IsIdentifier
, where both overrides just do the same thing,return node.IsKind(SyntaxKind.IdentifierToken)
. This proposal removes this extra clutter by having a new concept, abstract enumerations.Detailed design
Changes the syntax to:
MyAbstractEnum
cannot be passed(MyAbstractEnum)0
.byte
byte
, which implies that all derived enums are alsobyte
.Drawbacks
Alternatives
Unresolved questions
Design meetings
Beta Was this translation helpful? Give feedback.
All reactions