Allow designated initialization of struct

ryuukk_ ryuukk.dev at gmail.com
Thu Sep 12 13:46:55 UTC 2024


On Thursday, 12 September 2024 at 13:10:09 UTC, Sergey wrote:
> 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?

What did i expect?.. right i expect to switch language as soon as 
i find an alternative


Besides

Test[8] test = Test.init; // <- works

Data data = { test: Test.init }; // <- works

char[256] path = "/dev/null"; // <- works


Again, what do YOU expect?

D people still don't understand why the language is not more 
popular and why people leave after they play with it

I grew tired of trying to explain people how shitty things are 
for so long, wake up please


More information about the dip.ideas mailing list