Full closures for D

Nathan Reed nathaniel.reed at gmail.com
Tue Nov 6 23:17:59 PST 2007


David B. Held wrote:
> However, I think it would be nice to get rid of the 
> delegate type declaration altogether and git ourselves an implicit 
> delegate argument, like so:
> 
>    auto base = "/path/to/dir/";
>    auto absoluteDirs = map({ return base ~ $0; }, readdir(DIR));
> 

I think you're asking for too much intelligence form the compiler here. 
   Remember D is statically typed.  Without giving the parameter type 
for that delegate, we can't verify that its body is well-typed or that 
the call to map() is well-typed.  It is logically possible to infer the 
types in this case, but that goes way beyond the scope of what a D 
compiler should have to do - this isn't ML; we do type checking, but not 
full type inference.

Thanks,
Nathan Reed



More information about the Digitalmars-d mailing list