Extending D's support for object-oriented design with private(this)
NotYouAgain
NotYouAgain at gmail.com
Fri Apr 26 23:50:44 UTC 2024
On Friday, 26 April 2024 at 16:38:54 UTC, Steven Schveighoffer
wrote:
>...
> module m;
>
> class C
> {
> private(this) int _count;
> public void setCount(int c) { _count = c; }
>
> unittest
> {
> C c = new C();
> c._count = 42; // oops, this is still allowed
> }
> }
> ```
There is no 'oops' there.
The unittest is a member of the class!
It the unittest outside of the class that should not be allowed
to compile.
More information about the dip.ideas
mailing list