3 ms·
I would be interested if you can present a specific piece of code that would be really confusing to a programmer who does not have experience using languages wi
by mquander 17y ago
I would be interested if you can present a specific piece of code that would be really confusing to a programmer who does not have experience using languages with lexical closures. I didn't follow the same order of education, so I never really experienced an a-ha moment like that; they seem like a simple language construct to me (although I can definitely understand how it would be hard to recognize their utility without having experience using them.)
(I can understand how code passing around anonymous functions can be confusing to people who don't use a language with first-class functions, but I would figure they're confused by the logic, not by the closures.)
- btilly 17y agoThe line I presented to p5p went something like this: print join "\t", map {$format[$_]->($row[$_])} 0..$#format; http://www.perlmonks.org/index.pl?node_id=34786 http://www.perlmonks.org/index.pl?node_id=34786 has a longer code example which I used to introduce some idea of what closures could be useful for to a lot of Perl programmers.