[Static abstract?] Constants in interfaces #7631
Unanswered
Perksey
asked this question in
Language Ideas
Replies: 2 comments 10 replies
-
I'm not sure how this would work. Constants aren't really members, let alone virtual members. The call site is expected to be replaced by the compiler during compilation. This changes that concept drastically. |
Beta Was this translation helpful? Give feedback.
7 replies
-
What’s wrong with |
Beta Was this translation helpful? Give feedback.
3 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.
-
This is a significantly reduced scope variant of #6748
The proposal is to have constants in interfaces (similar to static abstract) such that generic parameters can be used in constant expressions (like attribute arguments). This enables the
ValueArray
use case that motivated @hez2010's constant generics MVP without creating a massive amount of work or committing to too many changes in the type system for a niche use case.Perhaps the above example shows how even this could be... umm... "well-used" by the community, but this feels like a minor addition and minor commitment at the language-level and runtime-level compared to constant generics while achieving most of the same effect.
Beta Was this translation helpful? Give feedback.
All reactions