Syntax sugar for {} with structs

Max Samukha maxsamukha at gmail.com
Fri Jul 1 20:21:45 UTC 2022


On Friday, 1 July 2022 at 19:03:25 UTC, Paul Backus wrote:

>
> ```d
> struct A {}
> struct B {}
>
> void f(A) {}
> void f(B) {}
>
> f({}); // ambiguous

Why is this more problematic than e.g.:

```d
void f(int[])
{
}

void f(byte[])
{
}

void main()
{
     f([]); // Nice ambiguity error
}
```
?


>
> void g(A) {}
> void g(int) {}
>
> g({}); // not ambiguous, but potentially confusing
>
> void h(A, B) {}
>
> h({}, {}); // not ambiguous, but potentially confusing
> ```

Same:

```d
void h(A[], B[]);
h([], []);
```



More information about the Digitalmars-d mailing list