|The stupid question is the question not asked|
Re^5: Near-free function currying in Perlby BrowserUk (Pope)
|on Nov 17, 2004 at 13:37 UTC||Need Help??|
(unless you tie the filehandle but please don't go there).
Frameworks in functional languages like lisp and Haskell do this too because it's easy to do for them as currying is built in and is the "natural" way to do this for their programmers.
I agree (partially), but tieing is a "natural" way in Perl.
Lisp and Haskell have to use currying, because FP languages eshew the concept of variables and state. So much so, that they had to invent "functions that you can only run once" (fancifully named 'monads') in order to get around the inconvenient reality that you cannot represent the real world as mathematical functions who's return values are always defined in terms of their inputs.
Files don't work that way; neither do databases or network connections or users. Perl very much lives in the real world. As LW put it "good chemistry is complicated, and a little bit messy". Perl has constructs for dealing with the real world very efficiently.
It just strikes me that trying to force-fit the FP function passing style on top of Perl is a kind square peg in a round hole thing.
Don't get me wrong. I'm really glad that Tom is posting this Haskell inspired stuff. It's helping me in my attempt to get to grips with Haskell. And I wouldn't try and stop anyone else from using it if they see what I don't. I'm just having a hard time trying to envisage the time when I would want to use currying in a Perl program.
All the examples I find of currying show (the equivalent of) things like
To which my reaction is "Whoo-pee?". And what's wring with print 2 * 3; ?
Tom at least came up with a vaguely plausible use for it, despite that I can't actually think of any time (with the possible exception of Tk; which I have issues with anyway:) that I might hav eused up till now.
Maybe the penny will drop for me one day soon. Or maybe I'll just have to confine myself to the backwater of inherently procedural thinkers--although I make full use of map, grep, List::Util::reduce et al. as well as having a growing collection of similarly FP-like functions of my own devizing.
So I have picked up on some of the concepts and grasped them with both hands. It's just finding a real-world "killer application" for some of the others, like currying, that leave me cold so far.