1.0 ?? [templates and currying]

Chris Nicholson-Sauls ibisbasenji at gmail.com
Tue Nov 7 16:11:47 PST 2006


BCS wrote:
> While the topic is function, "there arguments and what not" could we get 
> a fix to issue #52 (I think that is the number). As it stands, there is 
> no way to reference an overloaded function with out already knowing it's 
> type.
> 
> int foo(char c){return 0;}
> void foo(long l){}
> 
> auto fn = &foo;
> // the foo used changes if the order of the above changes.
> 
> this could also cause problems while attempting to call overloaded 
> functions the an overloaded function as a parameter
> 
> void fuf(int function(char) fn){}
> void fuf(void function(long) fn){}
> 
> fuf(&foo);    // what is used here
> 

Seems like it ought to be simple enough to provide this just by allowing a tuple of type 
symbols in the address-of-function expression.  Or in other words, to get the foo(long) in 
your first example, rather than foo(char) just do:
# auto fn = &foo(char);

which is still shorter than the explicit:
# int function (long) foo = &foo;

And again in your second example:
# fuf(&foo(long));

which has grown in this case, but not by a lot, and certainly the type information 
shouldn't be neccessary if there are no overloads.

-- Chris Nicholson-Sauls



More information about the Digitalmars-d mailing list