One of the most dangerous books I’ve ever even partially read is MJD’s Higher Order Perl. In particular, its description of subroutine currying — that is, building more specific functions out of more general purpose ones — is a pattern I find incredibly useful.
The other day I found myself writing a number of routines that were surprisingly similar… kinda. They all implemented a common pattern, but across routines that were rather… different. I found myself wistfully longing for the familiar pattern of currying, and then realized — I’m working in PERL, DAMNIT.
This is part of recent work of mine, extending Test::Moose::More to use subtests where they make sense. Here I was able to curry one function —
_validate_subtest_wrapper() — by passing it a reference to another function, that it then invokes.
Excellent. Life is easier, as it should be.