suggestion: default values

Gregor Richards Richards at codu.org
Thu Apr 19 22:58:27 PDT 2007


bobef wrote:
> It would be nice if there was some character like $ or something, if used as function argument, the default value for this argument to be used. What I mean is this:
> 
> void myfun(int a,char[] b,bool d=false,int e=55){}
> 
> void main()
> {
>     myfun(5,"5",$,$); // which should act like myfun(5,"5",false,55);
> }

Probably a better example of why this would be helpful:

void myfunction(int a, char[] b, Foo veryComplicatedThing = default, 
bool d = true) {}

void main()
{
     myfun(5,"5",$,false);
}



More information about the Digitalmars-d mailing list