Syntax sugar for {} with structs

Stefan Koch uplink.coder at googlemail.com
Sat Jul 2 16:42:20 UTC 2022


On Saturday, 2 July 2022 at 16:37:55 UTC, Nick Treleaven wrote:
> On Saturday, 2 July 2022 at 16:15:13 UTC, Ola Fosheim Grøstad 
> wrote:
>>> ```d
>>> struct S{}
>>>
>>> void f();
>>> void f(S s);
>>>
>>> f({}); // which gets called?
>>> ```
>>
>> It is a parameter list for the constructor of S, so `F(S s)` 
>> gets called.
>
> So in D we would need a new type for a constructor parameter 
> list. We already have parameter lists which have a type, but we 
> can't use that because it would call `f()`, not `f(S)`.

It could also be ambiguous in the above case.



More information about the Digitalmars-d mailing list