Function Literals
Russell Lewis
webmaster at villagersonline.com
Wed Mar 14 09:04:01 PDT 2007
abc() could be overloaded.
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.
>
> Is it possible to simulate a syntax like
>
> abc( (c) { return 6+b; } );
>
> using templates / mixins?
>
> Thanks for the advice!
>
> Falk
>
More information about the Digitalmars-d
mailing list