Please fix `.init` property

FeepingCreature feepingcreature at gmail.com
Tue Jan 9 06:16:42 UTC 2024


On Monday, 8 January 2024 at 18:03:00 UTC, Jonathan M Davis wrote:
> On Monday, January 8, 2024 3:57:52 AM MST FeepingCreature via 
> Digitalmars-d wrote:
>> Force default values to be typed immutable?
>
> That would require that there be a general way to copy an 
> immutable value to a mutable one, because the object must be 
> mutable after it's been default-initialized.
>
> Bastiaan's suggestion to make such cases illegal is probably 
> the only sane way to prevent these kind of issues, though I 
> think that it would have to be an error to have mutable 
> indirections with an allocation rather than illegal to point to 
> any allocations; otherwise, stuff like SysTime's member which 
> is Rebindable(immutable TimeZone) becomes illegal.
>
> - Jonathan M Davis

Yes, the point of making it forced `immutable` is exactly to make 
the problematic cases illegal. Don't even think about deepcopy vs 
array vs object etc., just let the const system handle it.


More information about the Digitalmars-d mailing list