Better lambdas!!!!!!!!!!

Ali Çehreli via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 10 11:02:35 PDT 2015


On 09/10/2015 10:55 AM, Prudence wrote:
 > How bout this:
 >
 > void myfunc(double delegate(int i, int z, float f)) {....}
 >
 >
 > myfunc((int i, int z, float f) { return i*z*f; } }
 >
 > vs
 >
 > myfunc({ return i*z*f; })   // Names of parameters are inferred from
 > signature.

Considering other features of the language, that's pretty much 
impossible in D. What if there is another i in scope:

int i;
myfunc({ return i*z*f; });

Now, should it call another overload of myfunc that takes (int z, int f) 
because i is something else?

Should the compiler analyze the body of the code and decide which 
symbols could be parameters? And then go through all overloads of 
myfunc? etc.?

Ali



More information about the Digitalmars-d mailing list