Sealed classes - would you want them in D?

KingJoffrey KingJoffrey at KingJoffrey.com
Tue May 15 05:13:26 UTC 2018


On Tuesday, 15 May 2018 at 04:46:18 UTC, Jonathan M Davis wrote:
>
> If you really insist on the viewpoint that class encapsulation 
> means that nothing outside of that class can access any of its 
> private members, then what D does definitely breaks 
> encapsulation. But having friends in C++ already provides a way 
> to break that.

No. That is not true.

friend is explicately part of the declared interface.

D on the otherhand, tells you who your friends are.

Your interface doesn't have a say in it anymore.

When your declared interface is moot, your enscapsulation is also 
moot.


> Regardless, I think that it's quite clear that we're not going 
> to convince KingJoffrey of anything, and it's unlikely that 
> he's going to convince us - though honestly, with that 
> username, I have to wonder if he's complaining about this issue 
> to just screw around with us for fun. But even if he's 
> completely serious, I think that it's clear that at best we're 
> going to agree to disagree.
>
> - Jonathan M Davis

I prefer to think of it as a discussion. Even though I'm right ;-)

But in any case, i feel I've presented some worthwhile arguements.

The only arguments I've got so far from the other point of view, 
is that's how D does it. If you don't like it, go wrute a DIP.



More information about the Digitalmars-d mailing list