Non-ugly ways to implement a 'static' class or namespace?

Ali Çehreli acehreli at yahoo.com
Tue Feb 7 16:16:48 UTC 2023


On 2/6/23 23:33, ProtectAndHide wrote:
 > On Monday, 6 February 2023 at 21:46:29 UTC, Ali Çehreli wrote:

 >> And as 'static class' and 'static struct' are already usable in D, a
 >> newcomer would definitely be confused with your "terrible" conclusion.

 > You being a little agressive don't you think?

I see how wrong that came out. Apologies! What I meant was "your 
conclusion [about something here being] terrible".

 > My observation is very reasonable, and correct,

Agreed.

 > The compiler will allow you to do all these things

Agreed.

 > I can see no reason why anyone would want to do these things, in this
 > context.

Agreed.

 > Nor can I see any reason, whatsoever, why the compiler would allow you
 > to do these things, in this context.

My understanding is that these are side-effects of trying to have 
orthogonal features. Some combinations don't make sense.

Having said that, since D does not use 'static class' for namespacing, 
should it go out of its way to implement logic to ban that combination 
at module scope? Perhaps. People have been discovering meaningless 
combinations of attributes in D all the time. (I forgot why that is so.)

If D disallowed 'static' at module scope, we wouldn't be having this 
discussion anyway. If that happened, then 'class' would be accepted for 
being used for creating objects.

Ali



More information about the Digitalmars-d-learn mailing list