Syntax sugar for {} with structs
Nick Treleaven
nick at geany.org
Sat Jul 2 16:37:55 UTC 2022
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)`.
More information about the Digitalmars-d
mailing list