auto type for defaulted arguments? [Repost]

bearophile bearophileHUGS at lycos.com
Thu Jun 27 10:42:12 PDT 2013


(This is an extended repost of a message that I have put in 
D.learn.)

Sometimes I have code like this:

struct VeryLongNamedStruct {}
void foo(in VeryLongNamedStruct x = VeryLongNamedStruct(1)) {}
void main() {}

Or even:

void bar(in TupleFoo x = TupleFoo(TupleBar(2), TupleSpam(3))) {}

In those cases something I'd like to use "auto" in the function 
signature for the arguments that have a default value:

void foo(in auto x = VeryLongNamedStruct(1)) {}

Do you like? Is it safe enough? Is it useful enough? Is it too 
much work to implement?

A bit more complex case:

void spam(T)(const x = Foo!T(4)) {}

Bye,
bearophile


More information about the Digitalmars-d mailing list