On Thursday, 25 January 2024 at 15:03:41 UTC, Max Samukha wrote:
On Monday, 22 January 2024 at 23:28:40 UTC, Jonathan M Davis
wrote:
Of course, ultimately, different programmers have different
preferences, and none of us are going to be happy about
everything in any language.
It's not only about preferences. The feature is inconsistent
with how 'invariant' and 'synchronized' are specified. They
imply class-instance-level private, while the language dictates
module-level. Consider:
```d
synchronized class C
{
private int x;
private int y;
invariant () { assert (x == y); }
static void foo(C c)
{
// mutate c
}
}
```
Same thing. Yet would still break with some sort of "class-only
private"
the unittest case is also similar -- what happens if you put the
unittest next to the function being tested? It's now in the
class, so it can access "true" private data. Same problems, this
even can happen in Java. I don't see what the difference is. Same
code, same file, just in a different spot? Seems more like you
just need to... not do that.
-Steve