Full closures for D
Robert Fraser
fraserofthenight at gmail.com
Wed Nov 7 01:11:12 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));
At first blush, it sounded like a really good idea to me (I use Perl quite a bit for hacking out quick scripts, though never in a functional manner). The problem, I feel, is the intended audience and purpose of a language.
Implicit function arguments, as well as being hard to implement, make code less readable and auditable. While Perl is great for smaller projects, having worked on a legacy system with ~1.5 million lines of Perl code, I can say it doesn't scale very well at all, and the lack of named arguments is a BIG part of that (since it takes longer to figure out what a subroutine does). Plus, in a big function/closure, you might not even be able to figure out how many arguments it needs without reading through the code.
In other words, implicit function parameters (whether inside or outside a closure) make hacking out a quick piece of code easy, but if you're working with a team of different experience levels or on a huge 100-man project, I could see that causing trouble.
* I say this without any background in functional anything (hopefully this spring I'll take a course in it and learn what all the fuss is about), but from what I know, pure-functional languages are rarely used in large systems.
More information about the Digitalmars-d
mailing list