private(this) vs LINT

forkit forkit at gmail.com
Mon Jun 27 23:39:00 UTC 2022


On Monday, 27 June 2022 at 20:23:26 UTC, Daniel N wrote:
> I was just thinking, if we had a standard linter, it could 
> solve many issues without bloating the language, since the 
> compiler exists as a library it should not be too difficult to 
> maintain either.
>
> This way we can both keep the cake and eat it.

I could not disagree more.

'classes' and 'information hiding' are 'entangled'.

I've seen many arguments against adding private(this), but no 
argument (that can be taken seriously), that you shouldn't be 
able to apply the 'information hiding' principle to a class.

In D, you're told you can do this by putting the class it's own 
module.

My argument, is that this principle is so tightly entangled with 
the class concept, that it should be availabe to do with the 
class type itself.

I think, in principle at least, my argument is a stronger 
argument, than the one-class-to-a-module argument.

But why you would want to bring a linter in to solve this, 
puzzles me even more than a language that supports classes, but 
doesn't having a means (an option) to apply the information 
hiding principle *within* the class type itself.

In terms of the ever increasing move towards being able to 
improve the provability of your code, then yes, a linter will 
have to come into play.



More information about the Digitalmars-d mailing list