Using closure in function scope to make "real" private class members

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Tue Jun 7 05:05:53 UTC 2022


On Monday, 6 June 2022 at 23:05:29 UTC, zjh wrote:
> As long as `attributes` can solve my problem, I don't care how 
> many `attributes` there are.
> I `like` `attributes`.

Adding many variations of the same just makes code harder to read 
and mistakes easier to make.

In most languages «private» has the same meaning. In D it has a 
slightly different meaning. That is ok, but somewhat annoying.

If you now add «@private», which means the same as «private» in 
other languages, then experienced programmers will be confused 
and demand an explanation. In other words they will ask «what the 
hell went wrong in the design process, this is a mess».

A well designed language has a small and  expressive core.

Adding special cases is not good, especially not if you have 
generic programming features.

These are well established facts that all scholars agree upon.

More mostly redundant stuff makes things worse, not better. If 
there are issues, go back to the drawing board and fix the core 
language.







More information about the Digitalmars-d mailing list