On 2/18/22 07:01, kdevel wrote:

>     Error: struct `B` has constructors, cannot use `{ initializers }`,
>     use `B( initializers )` instead
>
> What is the rationale behind that? I mean: If the compiler exactly
> sees what the program author intends to express why does it force the
> author to change the code?

I don't know the answer to that. The {} initializers always seemed out of place to me. I assumed they had to be supported to copy+paste C code to D and it should mostly work.

One benefit of the {} initializer is being able use named initializers:

struct S {
  int a;
  int b;
}

void main() {
  S s = { b : 2, a : 1 };
}

I still think it's out of place. :)

I think that syntax will be obviated when D will have named arguments.

Ali

Reply via email to