base::StaticMember syntax #9134
Replies: 4 comments 5 replies
-
How painful is it to declare an alias in the file? |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Reminds of me this proposal: If there was a keyword to qualify static members without the full type name maybe it could be extended to this case? protected static new readonly string Name = base(class).Name + " MyClass"; |
Beta Was this translation helpful? Give feedback.
-
I just came across another reason why it's desirable to have this syntax - copying and pasting classes. Yes, I know 2 classes should not be a copy of each other, but I frequently start working on adjacent features by using an existing closely-related class as a template - think another UI element, etc. When both original and "cloned" classes use this pattern (reference a hidden base static member), and the base class changes, I have to remember to change those references (which I sometimes forget to do). If those references were |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
If the base class is a generic type, especially with many type arguments, referencing static members on it (this is specifically a pain point when "hiding" those static members) becomes very long:
It would be much easier to do something like this:
Needless to say, I'm not stuck on
base::
syntax, but it does look like it can work - not ambiguous, easy to write, etc.Beta Was this translation helpful? Give feedback.
All reactions