auto type for defaulted arguments? [Repost]

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Thu Jun 27 13:24:42 PDT 2013


On Thu, 27 Jun 2013 19:58:58 +0200
"Maxim Fomin" <maxim at maxim-fomin.ru> wrote:

> On Thursday, 27 June 2013 at 17:42:14 UTC, bearophile wrote:
> > (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?

I've noticed a need for that, too.

 
> but auto can be used in paramenters too.

It can? Cool!



More information about the Digitalmars-d mailing list