Allow struct constructors with all parameters optional

Lance Bachmeier no at spam.net
Thu Aug 29 13:20:04 UTC 2024


On Thursday, 29 August 2024 at 09:37:53 UTC, Ogi wrote:
> On Wednesday, 28 August 2024 at 15:26:47 UTC, Lance Bachmeier 
> wrote:
>>>
> This proposal is not about allowing default struct 
> constructors. Under this proposal, `S()` would still be 
> initialized with `S.init`.

I'm not sure I understand. This is what you wrote:

> D disallows parameterless constructors for structs, and there 
> are good reasons for this. But constructors with all parameters 
> optional are prohibited too. This restriction doesn’t make much 
> sense, especially now when D supports named arguments. This 
> should be valid:

My example shows that it *is* valid, but only if you jump through 
unnecessary hoops.


More information about the dip.ideas mailing list