| |
 | Posted by forkit in reply to Ali Çehreli | Permalink Reply |
|
forkit 
Posted in reply to Ali Çehreli
| On Saturday, 4 June 2022 at 07:04:35 UTC, Ali Çehreli wrote:
>
> ...
> I think the reason is there is no strong argument for one way or the other. There are two options:
>
> a) 'private' means "private to the class", which necessitates the equivalent of the keyword 'friend'. This option is what C++ chose.
>
> b) 'private' means "private to the module", which frees 'friend' as a user symbol. This option is what D chose.
>
> > I really do think there is idealogical resistance to such a
> change, and
> > it's this that brings about these strong reactions.
>
> Since D came after C++, it is clear that option b was seen to be superior. Let's hear arguments why option a is better than b.
It's interesting that whenever this topic is brought up, that people in the D community (like you, for example), try to rephrase it as if we're all being forced to make a choice between A *or* B.
I'd like to have A *and* B.
You normally come up with ideas to issues that people raise (even ideas that to me see pretty ordinary), except, when it is this issue??
Why this idea encounters sooo.. much resistance, is..well. interesting.
The rest of your response I couldn't make any sense of.. so I'll ignore it.
In the end though, encapsulation of a class, in D, is broken, and cannot be statically verified by the compiler, unless you put that class in it's own file (which is what you're expected to do anyway, based on the reponses this idea always provoke).
Since there is no option B, to do otherwise, is what I would consider unsound programming, as it is not possible to reason about the code of the class contained within a module, without understanding ALL the code in that module.
It's also not possible to prove (again, without human intervention) that other code in the module does not violate the modular requirements of the class.
A possible counter agrument to the above, is that there is no encapsulation of a class in D. The module provides all the encapsulation anyone will ever need.
I'm not sure I'd want to be on that side of the argument ;-)
|