Named arguments via struct initialization in functions

arturg via Digitalmars-d digitalmars-d at puremagic.com
Tue Mar 8 10:36:03 PST 2016


hi, has the UDA syntax been proposed already?

void fun(int foo, int bar, int bazDaz = 0){}

fun(10, 30, 50); // normal
fun(10, 30); normal with default

fun(10, 30, @bazDaz 50); // mixed
fun(@bazDaz 50, 10, 30) // mixed and reordered
fun(@bar 30, 10); // mixed, reordered and default

fun(@foo 10, @bar 30, @bazDaz 50); // named
fun(@bar 30, @bazDaz 50, @foo 10); // named and reordered

@foo int a = 10;
@bar int b = 30;
@bazDaz int c = 50;

fun(c, a, b); // hm allowed or not?

but if built in tuples could be used to do named args then it 
might be better to have those.



More information about the Digitalmars-d mailing list