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

forkit forkit at gmail.com
Tue Jun 7 23:59:42 UTC 2022


On Tuesday, 7 June 2022 at 18:07:34 UTC, Andrey Zherikov wrote:
>
> Regarding implementation. I don't like `@private` as people 
> will be confused a lot with `@private`<->`private`. IMHO the 
> ideal solution would be having `module` to mark module privates 
> and `private` for real privates but this is not backward 
> compatible. So the better solution might be extending syntax 
> for `private` having something like `private(symbol[, symbol 
> ...])` where `symbol` is a symbol that has access to the member 
> For example: `this` means current struct/class; `this.foo` or 
> `<typeof(this)>.foo` means foo member in the current 
> struct/class.

Yes. I agree. @private is not descriptive enough.

private(module) on the otherhand, states its purpose very clearly.


More information about the Digitalmars-d mailing list