dmd 2.029 release

bearophile bearophileHUGS at lycos.com
Mon Apr 20 02:48:11 PDT 2009


Walter Bright:
> void foo(alias f)()
> {
>      f(3, 4);
> }
> foo!((x,y){return x * y;))();

I have tried:

import std.stdio: writeln;
void foo(alias f)() {
    f(3, 4);
}
void main() {
    foo!( (x, y) { writeln(x * y); } )();
}

And it works, printing 12 :-) Very cute.
This is able to simplify some of the code of (D1) dlibs :-)

I didn't even know that lambda delegates in D2 can now infer the type of their input argument, so you can use (x, y) instead of (int x, int y). Can you tell me when this was changed? :-)

Bye,
bearophile


More information about the Digitalmars-d-announce mailing list