Allow designated initialization of struct

Steven Schveighoffer schveiguy at gmail.com
Fri Aug 30 19:37:22 UTC 2024


On Friday, 30 August 2024 at 16:02:38 UTC, ryuukk_ wrote:
> This should be allowed:
>
> ```D
> struct Data
> {
>     int a;
>     int b;
>     int c;
>     @disable this();
> }
>
> my_fun( Data { c: 1 } );
> ```


I'm not understanding the `@disable this()`

Without that, this works:

```d
struct Data
{
     int a;
     int b;
     int c;
}

void my_fun(Data data) {}

void main()
{
     my_fun( Data (c: 1 ) );
}
```

I tried making Data also have a ctor with all defaults, but it 
doesn't like that.

-Steve


More information about the dip.ideas mailing list