Function pointers/delegates default args were stealth removed?

Carl Sturtivant sturtivant at gmail.com
Mon Aug 27 03:18:51 PDT 2012


>
> That's a great idea Carl! You mean something like this:
>
> int sum(int a, int b) {
>   if( argc == 1 ) b = 1; //default for b if not supplied
>
>   return a + b;
> }
>
> //...
>
> auto f = ∑
>
> //...
>
> auto x = sum(y);  //function pointer call, so fewer args 
> permitted

oops! last line was supposed to be:

auto x = f(y); //function pointer call, so fewer args permitted

And for the record, 'argc' in the above is a name that has a 
similar status to 'this' and is equal to the number of arguments 
actually passed. Probably there's a better choice of name.




More information about the Digitalmars-d mailing list