What to do about default function arguments

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Thu Apr 26 06:09:15 PDT 2012


On 26/04/12 05:44, Walter Bright wrote:
> But if we make default arguments solely a part of the function declaration, then
> function pointers (and delegates) cannot have default arguments. (And maybe this
> isn't a bad thing?)

I can't see disallowing default arguments as being a good thing.  For example, 
instead of,

     void foo(int a, int b = 2)
     {
         ...
     }

surely I can just put instead

     void foo(int a, int b)
     {
         ...
     }

     void foo(int a)
     {
         foo(a, 2);
     }

... and surely I can do something similar for function pointers and delegates. 
So, I can still have default arguments in effect, I just have to work more as a 
programmer, using a less friendly and easy-to-understand syntax.  That doesn't 
really seem like a good way to operate unless there's an extreme level of 
complication in getting the compiler to handle the situation.


More information about the Digitalmars-d mailing list