Syntax sugar for {} with structs

Paul Backus snarwin at gmail.com
Fri Jul 1 21:01:43 UTC 2022


On Friday, 1 July 2022 at 20:21:45 UTC, Max Samukha wrote:
> Why is this more problematic than e.g.:
>
> ```d
> void f(int[])
> {
> }
>
> void f(byte[])
> {
> }
>
> void main()
> {
>     f([]); // Nice ambiguity error
> }
> ```

It's not. I'd say they're both equally problematic.

Array literals are useful enough in general that we're willing to 
accept this problematic special case in order to have them. It's 
not obvious to me that the proposed `{}` meets the same standard. 
Maybe if the proposal were for some kind of "struct literals", 
rather than just `{}` by itself, it would be more attractive.


More information about the Digitalmars-d mailing list