Full closures for D

David B. Held dheld at codelogicconsulting.com
Wed Nov 7 23:15:14 PST 2007


Bill Baxter wrote:
> [...]
> In python the lambdas still requires arguments to be named, and use of 
> the 'lambda' keyword.  So it'd be something like:
>     absDirs = map(lambda x: base + x, readdir(DIR))
> 
> I'd prefer that middle ground to perl's magic variables.  Make it so the 
> type can be inferred, but the user still has to give it a name.  Maybe:
> 
>    auto base = "/path/to/dir/";
>    auto absoluteDirs = map((x){ return base ~ x; }, readdir(DIR));
> 
> But I find the the Python (or Perl) much easier to look at without all 
> the (){}; business around the anonymous function.

I agree that anonymous lambda args are probably going a step too far. 
Andrei proposed the same as you (type-inferred named args), and I think 
it's a good compromise.

Dave



More information about the Digitalmars-d mailing list