Syntax sugar for {} with structs

Stefan Koch uplink.coder at googlemail.com
Fri Jul 1 22:09:12 UTC 2022


On Friday, 1 July 2022 at 19:21:28 UTC, ryuukk_ wrote:
> `A a = {};`

that works because it is unambiguous in struct init context.
Whereas `{}` anywhere else is an empty function literal.
That's also the reason why D cannot use `{ }` for tuples.

Now one could make that case that an empty function literal is 
useless and so is one containing a sequence of values, without a 
return statement.

and you could reasonably introduce c++ like braced  value 
sequences to be used as initialization expressions.

As far as I can see that wouldn't clash with existing syntax.


More information about the Digitalmars-d mailing list