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

Mike Parker aldacron at gmail.com
Fri Jun 3 11:50:22 UTC 2022


On Friday, 3 June 2022 at 10:37:28 UTC, forkit wrote:

>
> Not necessarily. The overall goal should be encapsulation 
> (hence in D, the one class per module recommendation). But the 
> goal of encapsulation is to manage complexity and support local 
> reasoning. It's not an excuse to force programmers to put each 
> class in its own module, in order to statically enforce its 
> represenation.

And in D you encapsulate at the module level. We don't need 
another keyword for more fine-grained encapsulation, because we 
already have a solution in the form of the package module.


More information about the Digitalmars-d mailing list