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

forkit forkit at gmail.com
Wed Jun 8 10:50:32 UTC 2022


On Wednesday, 8 June 2022 at 10:30:59 UTC, Ola Fosheim Grøstad 
wrote:
>
> They would also ask what "private class" means.

That's easy to solve ;-)

It's simple. People will know if its documented (I mean how else 
do they know, that private is not really private - cause it says 
so in the documentation - or they discover it by mistake (more 
likely).

A really minor change to the existing documentation, as such, and 
it's done:

https://dlang.org/spec/attribute.html#visibility_attributes

1. Visibility is an attribute that is one of private, private 
(this), package, protected, public, or export. They may be 
referred to as protection attributes in documents predating DIP22.

2. Symbols with private visibility can only be accessed from 
within the same module. Symbols with private (this) visibility 
can only be accessed from within the abstraction in which it is 
defined, and can be applied to a class or struct only.



More information about the Digitalmars-d mailing list