private keyword dont appear to do anything

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sat Nov 4 11:55:20 UTC 2017


On Saturday, November 04, 2017 11:03:52 Paolo Invernizzi via Digitalmars-d-
learn wrote:
> On Friday, 3 November 2017 at 23:32:52 UTC, H. S. Teoh wrote:
> > [...]
>
> What's wrong with the introduction of another visibility
> attribute that behave like the C++ private?
>
> Just curious...

Well, if a good enough DIP could be written to convince Walter and Andrei,
then I'm sure it could be added, but it probably isn't worth it. If you
really want that level of separation, then you can always just put your
class or struct in its own module, and in practice, the fact that other
stuff in a module _could_ access the private members of a struct or class
doesn't tend to be a problem - and adding yet another access modifier does
make the language and its implementation that much more complicated. It also
might break existing code that uses type introspection and has logic based
on what access level a symbol has.

Ultimately, while I don't think that there's any technical reason why we
couldn't make such a change, I think that it's trying to solve a problem
that doesn't really exist, and for the change to be made, a solid argument
would have to be made as to why it's a real problem that needs fixing and
why the proposed solution is the right one.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list