Anonymous structs

MattCoder mattcoder at hotmail.com
Mon Feb 11 14:58:36 PST 2013


On Monday, 11 February 2013 at 21:30:52 UTC, Jacob Carlborg wrote:
> The advantage of anonymous structs is that they can be declared 
> in place, in function declartions for example:
>
> void foo ({ int x, int y } point)
> {
> }
>
> foo({ y: 5, x: 3 });

At the first look it seems interesting, but imagine that you need 
to change one type or add more members to that struct, have you 
imagined the mess to change all those declarations?

Because that case I prefer the old way:

void foo(MyPointStruct point)
{
}

Any changing in "MyPointStruct" will be consumed by all the code.


More information about the Digitalmars-d mailing list