Allow designated initialization of struct

Sergey kornburn at yandex.ru
Thu Sep 12 13:10:09 UTC 2024


On Thursday, 12 September 2024 at 12:14:17 UTC, ryuukk_ wrote:
> Today i tried this:
>
>
> ```D
>
>
> struct Test
> {
>     int test;
> }
>
> struct Data
> {
>     Test[8] test;
> }
>
> void add(Data data)
> {
> }
>
> extern(C) void main()
> {
>     add( Data(test: [ {test: 1}] ) );
> }
>
> ```

```d
struct Test
{
     int test;
}

struct Data
{
     Test[8] test;
}

void add(Data data)
{
}

extern(C) void main()
{
     add(Data(Test(1).repeat(8).array.to!(Test[8])));
}
```

What did you expect to initializing an array of 8 elements with 1 
value? all the same?



More information about the dip.ideas mailing list