Passing function parameters by name

Kirk McDonald kirklin.mcdonald at gmail.com
Tue Dec 4 13:38:24 PST 2007


bearophile wrote:
> Robert Fraser:
> 
>>The call is bound at compile-time,
> 
> 
> I can't understand how you can fully solve that problem I have shown at compile time. A function pointer can be managed at runtime, so at runtime you can choose to give or to not give the default parameter...
> 
> Bye,
> bearophile

Function pointers don't know anything about default parameters. That is, 
the following does not work:

void foo(int i=20) {}

void main() {
     void function() fn = &foo; // Error: typeof(&foo) is
                                // void function(int)
     fn();
}

-- 
Kirk McDonald
http://kirkmcdonald.blogspot.com
Pyd: Connecting D and Python
http://pyd.dsource.org



More information about the Digitalmars-d mailing list