Non-ugly ways to implement a 'static' class or namespace?
ProtectAndHide at gmail.com
Tue Feb 7 07:33:30 UTC 2023
On Monday, 6 February 2023 at 21:46:29 UTC, Ali Çehreli wrote:
> On 2/6/23 12:56, ProtectAndHide wrote:
> > I'm not going to 'go write a
> > DIP'.
> Nobody will write a DIP about it because very few people ever
> mentioned this issue over the years.
> And as 'static class' and 'static struct' are already usable in
> D, a newcomer would definitely be confused with your "terrible"
You being a little agressive don't you think?
My observation is very reasonable, and correct, and a new comer
to D would do well to know that:
The compiler will allow you to do all these things, even if
you've @disable'd' the constructor, and have only static members:
- the compiler will allow you to declare a variable of that type
- the compiler will allow you to declare an array with elements
of that type
- the compiler will allow you to use that type as a type argument
- the compiler will allow you to use that type as a parameter
- the compiler will allow you to use that type as a return type
I can see no reason why anyone would want to do these things, in
Nor can I see any reason, whatsoever, why the compiler would
allow you to do these things, in this context.
It's not about me trying to remove power from the programmer.
That's a nonsense argument, without any basis, whatsoever. It's
just a (correct) observation.
Further comments that try to derail this will be ignored.
More information about the Digitalmars-d-learn