Adding a new design constraint to D

forkit forkit at gmail.com
Thu Jun 16 23:31:28 UTC 2022


On Thursday, 16 June 2022 at 11:10:33 UTC, Kagamin wrote:
>
> ...
> When you have a lazily initialized field, you need to use an 
> accessor, because if you read the raw field, you get an 
> uninitialized value and error as a result, so only the accessor 
> should have access to the field.

I think the answer here, is that if you can't access a lazily 
initialized field because you made it 'private(scope)', then 
don't make it 'private(scope)'.

'private(scope)' is not meant to replace anything.

'private(scope)' would just be a design constraint 'option' (an 
option that so many of us have had for decades), for you to use 
when you think it is appropriate for you to use. You explicately 
state your intent with it, and the compiler will know and enforce 
that intent (at compile time).



More information about the Digitalmars-d mailing list