Using closure in function scope to make "real" private class members
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Sat Jun 4 07:28:13 UTC 2022
On Saturday, 4 June 2022 at 07:04:35 UTC, Ali Çehreli wrote:
> Since D came after C++, it is clear that option b was seen to
> be superior. Let's hear arguments why option a is better than b.
>
As already stated, when changing the model you want encapsulation
to be tight. Stronger typing is always better in this setting.
«Friend» is useful in larger apps when you need access on another
layer for performance or concurrency reasons. It documents
exactly what you need to look at when changing invariants.
But D has other stuff to fix, so there is no reason to fix this
one. Most D programs are not so large that it matters all that
much.
More information about the Digitalmars-d
mailing list