Non-ugly ways to implement a 'static' class or namespace?
ProtectAndHide at gmail.com
Sat Feb 18 05:41:00 UTC 2023
On Friday, 17 February 2023 at 22:58:19 UTC, ProtectAndHide wrote:
Actually, I just now understand 'why' (as opposed to 'how')
private works in D the way it does.
In D, private within a module is (more-or-less) like static used
in C outside of a function.
That is, in C it restrains the visibility to the current file,
and so it does in D (visibility to the current module).
ok fine. That works well in C.
But C does not have classes! (user defined types with their own
So what would happen if C got classes then?
Well, we already know -> C++ (private declared within a
user-defined type, restrains visibility to that type). And so it
So in essence, the D module is still stuck in the C era it seems.
Now I'm fully convinced that OOP should never, ever, ever, be
done in D.
Now I can finally move on ;-)
More information about the Digitalmars-d-learn