Function Literals
Walter Bright
newshound at digitalmars.com
Wed Mar 14 11:15:54 PDT 2007
Falk Henrich wrote:
> Hi!
>
> I'm just experimenting with delegates and came across
>
> http://www.digitalmars.com/d/expression.html#FunctionLiteral
>
> where one finds this example:
>
> int abc(int delegate(long i));
> void test()
> { int b = 3;
> abc( (long c) { return 6 + b; } );
> }
>
> My question is: If the compiler can infer the return type of the anonymous function, how come it can't infer the type of the parameter c? Forgive me if this is too stupid a question, but I thought: if the compiler knows the signature of abc it has to be clear that c is of type long.
The problem is it doesn't know the function signature of abc, since abc
may be overloaded, and may even be a function template.
More information about the Digitalmars-d
mailing list