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

Arafel er.krali at gmail.com
Wed Jun 8 11:11:05 UTC 2022


On 8/6/22 12:58, bauss wrote:
> Because functions cannot be package __and__ virtual.

Good reason, indeed. Well, I guess it technically can, if all your 
subclasses are in the same package (or at least branch). Agreed, not too 
useful in the general case, though.

Would it make sense however to make `protected` behave like it does in 
java [1], and include `package` visibility? Given that AFAIK D took most 
of its OOP ideas from Java, I think it wouldn't be too far-fetched.

Perhaps another option would be to add an optional parameter like 
`package` already does to activate this functionality, or to just allow 
both keywords: `protected package`.


[1]: https://docs.oracle.com/javase/specs/jls/se18/html/jls-6.html#jls-6.6.2


More information about the Digitalmars-d mailing list