Why is D unpopular?

Max Samukha maxsamukha at gmail.com
Wed May 18 17:04:01 UTC 2022


On Wednesday, 18 May 2022 at 16:02:52 UTC, Paul Backus wrote:
>
> With DIP 1030 implemented, D's struct literals will achieve 
> feature parity with C99's compound literals (which are also not 
> anonymous--they require you to specify the type using a 
> cast-like syntax).

In C, you only have to specify the top level type:

struct Foo {
     int x;
};

struct Bar
{
     struct Foo f[2];
};

int main()
{
     struct Bar b;
     b = (struct Bar){{{1}, {2}}};
     // or just
     b = (struct Bar){{1, 2}};
     return 0;
}

In D, you would have to:

b = Bar([Foo(1), Foo(2)]);



More information about the Digitalmars-d mailing list