Default initialization no longer a thing

deadalnix deadalnix at gmail.com
Tue Oct 24 01:35:16 UTC 2023


On Monday, 23 October 2023 at 22:45:29 UTC, Paul Backus wrote:
> On Monday, 23 October 2023 at 18:54:45 UTC, IGotD- wrote:
>> What is your take on this and if D would ever be modernized, 
>> is this something that D should consider?
>
> Most of the time, default initialization is what you want, and 
> it doesn't cause any problems. So I think having default 
> initialization by default but allowing the programmer to opt 
> out is probably the right way to handle this.
>
> Currently, D allows you to `@disable this()` for user-defined 
> types, but it doesn't give you any way to opt out of `T.init`. 
> This is something that should be improved. If disabling 
> `T.init` entirely is too disruptive, there should at least be a 
> way to make `T.init` accessible only in `@system` code.

@disable this plain doesn't work. It prevent things in some 
cases, but utltimately fails to enforce the invariant it sets out 
to enforce.


More information about the Digitalmars-d mailing list