On 2/5/23 18:15, ProtectAndHide wrote:
> I do not agree, that a compiler that allows a programmer to misuse a
> type
Types normally have objects. If a programmer found a way to use objects
of a memberless type why stop them?
> should be seen as 'a feature'.
I am not saying I already see those uses as features. I am questioning
why the compiler should ban certain features. Rather, why would a
programmer decide that another programmer should not have objects of a
certain type?
What is the actual insurmountable problem here? C#'s having 'static
class' cannot be an answer because I can't imagine somebody even in C#
wanted to have such a thing. For all I know, they wanted something else
(namespacing in this case) and implemented it as 'static class'.
On the other hand, it is possible that C# brings different semantics
that I don't know yet. What is that semantics? How does D already solve
that?
> If that's the kind of 'power' D programmers want,
The trait here is orthogonality: Let's say A, B, C, etc. are features of
a language. Some combination of those features work together for various
reasons.
On the other hand, some combinations may not work well and people don't
or can't use them for various reasons:
- The language may ban them because there may be dangerous ambiguities
with that combination
- There may be technical impossibilities for that combination
- That combination can have no agreeable semantics (your earlier
examples are in this category)
- People would never think about that combination (to me, at least some
of your examples are in this category)
- People may decide not to use that combination in coding guidelines
- etc.
So, what I am understanding is that thebluepandabear and you are asking
the compiler to ban certain combinations. For example, using a struct
for namespacing (A) and being able to create objects (B) used together
should not be allowed.
What other combinations can we come up with for such a list? As you
said, certain uses of the 'static' keyword at module scope has no effect
in D ('statis this' and 'shared static this' should be considered
multi-word keywords and I think 'static const' has a meaning). Should
the D spec enumerate all ineffective uses of 'static' (and others) and
ban them? I don't agree.
In contrast, D delivers some features in an unprincipled way and the
programmers use combinations of those features the way the see fit.
I really don't care if D had 'static class' to be used only as a
namespace but I don't see how this issue is terrible. If the programmers
ever need to use a struct (or a class) for namespacing then they
wouldn't need objects of such types either. So, they wouldn't do that.
Ali