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

forkit forkit at gmail.com
Wed Jun 8 11:25:46 UTC 2022


On Wednesday, 8 June 2022 at 11:18:42 UTC, Ola Fosheim Grøstad 
wrote:
> On Wednesday, 8 June 2022 at 11:07:39 UTC, forkit wrote:
>> I wouldn't object to 'hidden int x'.
>
> It is at least easy to understand.
>
>
> (Simula had "hidden", "protected" and "hidden protected" 
> (private), but that doesn't matter ;-)

Interesting that Scala has 'private[this]'

https://stackoverflow.com/questions/9698677/privatethis-vs-private

Still, I think I'd prefer 'hidden' actually. It's pretty clear 
what you're stating here with that word. And, you can't confuse 
it with a contructor like 'this()'.

But it would require the addition of a new keyword, which takes 
the idea to a whole new level :-(

The addition of new keyword is really something I'd want to 
avoid, if at all possible.

perhaps 'private class' and 'private struct' makes more sense 
after all.


More information about the Digitalmars-d mailing list