On Tuesday, 7 February 2023 at 16:16:48 UTC, Ali Çehreli wrote:
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
Well, in C++ I can just mark the destructor as = delete;
The compiler now won't let me do those things that D would allow.
D could do something similar I guess, with: @disable ~this();
In fact, a static class is a very useful abstraction.
C# just makes it 'easy' for the programmer to define it as such,
without all the nonsense other languages require. In addition,
the C# compiler WILL prevent nonsense code, which is exactly what
I want from a compiler ;-)
When a compiler allows nonsense code, my confidence in it begins
to wane...