On 08/07/2024 15:13, Alexandru Pătrănescu wrote:
But I understand that once a class is static, all the chain of
inheritance should be made of static classes, going up or down (and I
would also think we can add interfaces and traits.).
Correct.
If interfaces are not included, do we allow implementing an interface?
Yes.
If we allow implementing an interface, should that interface contain
only static members?
Yes. You can technically implement an interface that has instance
methods, but you will either: get a compile-time error that you didn't
implement the instance method, or a compile-time error that you didn't
mark the (instance) method as static in a static class. So although you
won't get an error about implementing the interface itself, you will be
forced to not implement an interface containing any instance methods in
a static class, by one of those two (somewhat indirect) errors.
Same for traits.
Yes
For completeness, if we think that the static keyword on a class-level
entity means that it will allow only static members on that entity,
all class-level entities should be able to be marked as "static".:
I understand that sentiment, however I'm still not going to entertain it
right now because this RFC seems to have a tenuous chance of passing at
best. I should think we will be lucky to get 50% of the vote, let alone
the 66% required to pass, and any further (unnecessary) language
changes, such as introducing `static interface` or `static trait`s will
probably lower those odds. I'm sorry it's like that, but that's how the
landscape looks to me. But not to be too disheartened; both of those
things can be trivially added in a follow-up PR if there is a strong
desire. That is, accepting this RFC in no way precludes the possibility
of going down that road later.
Cheers,
Bilge