private(this) vs LINT
forkit
forkit at gmail.com
Tue Jun 28 21:29:55 UTC 2022
On Tuesday, 28 June 2022 at 20:58:56 UTC, Daniel N wrote:
>
> But what if your favourite editor automatically highlighted the
> entire line with red?
>
my favourite editor, is the one I wrote myself ;-)
>
> After being exposed to D, I usually end up trying to emulate it
> when I am forced to work in other languages. For this reason
> some of my C++ files are filled with 20+ friend declarations
> just so I can do what I want inside that file...
>
But C++ gives *you* a choice right?
I'm not sure continuing to compare D to C++ is all that benefical
anymore.
I'd recommend you have a look at Swift. Then try comparing D to
Swift, and you will come to very different conclusions.
> Some people hate goto and some love it.
Again, *you* can choose to use goto, or not.
You *cannot* chose to 'explicately' declare private members,
within the class itself. D has made the design choice for you.
The are pros and cons for that decision. But the biggest con, is
that this choice has been completely eliminated from the language.
You have that choice, in C++, C#, Java (erhh!), Swift,
Javascript.......
Those languages represent a pretty big portion of programmers
worldwide - who may or may not use private member variable in
their day to day tasks, but they all have the choice to do so, or
not.
There's really no 'nice' way to frame this. Removing 'choice' for
this very substantial idiom, is one of D's biggest design
failures IMO. (yes, others have a different opinion, which of
course is just fine. This is just mine).
I cannot use classes in a language where I have to **constantly**
write notes in the code, just to remind myself, and others, to
use the public interface, and not directly read/mutate a private
member.
Again, that mistake I initially made in the unittest of that
unsafeVector code I put in my post, was a *genuine* mistake I
made only yesterday!
I don't know what the solution to that is. Put every unittest of
a class in its own module perhaps?
More information about the Digitalmars-d
mailing list