private(this) vs LINT

forkit forkit at gmail.com
Tue Jun 28 20:29:27 UTC 2022


On Tuesday, 28 June 2022 at 16:06:54 UTC, Daniel N wrote:
>
> Yes, but I know Walter, he mentioned many times his dislike for 
> compiler switches and warnings and he raised some very good 
> points, which I partially agree with, but his dislike of 
> switches is even stronger than mine.
>

Well. In this case, Walter is right ;-)


> Imagine four innocent small switches -A -B -C -D, if you can 
> toggle all of these the result is a combinatorial explosion, 
> because some bugs might only manifest in certain combinations 
> and thus the required testing time increases greatly.
>

That's why I would not accept the -fe thing you mention.

The correctness of my unittest should not depend on whether i 
remember to use a specific compiler switch.

> If "we" make our own tools with stricter warnings that can be 
> tuned to everyones individual preference, there is 0 risk of 
> compiler regressions.

There is a case to be made, for a linter, obviously.

I disagree strongly, that a linter should be used to verify the 
encapsulation of a class (in terms of what something like 
private(this) would do.)

This is not a 'personal preference'. I wish people would stop 
using that argument against the idea. The ability to selectively 
make member variables private to the class, is something millions 
of programmers have at their finger tips everyday, and have had 
it, for decades!

The principle of information hiding, is at the core of good 
programming practice.

Indeed, everything in a module is pretty much hiding something. I 
just cannot fathom why a programming language would not have an 
option to do that explicately for a class type. I've never heard 
an argument that makes even the slightest sense to me.

I do feel sad, that I cannot promote D over here in Australia, 
because it just fails to recognise the importance of this, in the 
life of millions of programmers.

It's an established idiom, that you cannot do in D. It's really 
sad. That code I presented is why I still don't use classes in D, 
even after using D for almost 7 years now.

Instead, people seem more interested in '=>' than encapsulation ??




More information about the Digitalmars-d mailing list