|
![](/i/fill.gif) |
>> If you're writing a mathematical theory about which computations are
>> possible, then only having to worry about 1-arg functions makes the
>> theory simpler. That's why the lambda calculus does it that way.
>
> I can believe that. However, what I was really asking was what's the
> advantage of having only one-argument functions in a practical programming
> language.
Sure, I get that. I was just adding a point of context.
>> It's useful to be able to quickly throw together a new function by just
>> writing a partial call to an existing one.
>
> That seems to be a very specialized case. There are tons of other
> combinations (eg. in terms of the number of parameters to a function,
> among many other things) that can be equally useful.
You'll notice that Haskell programmers are very particular about the
order in which a function takes its arguments - because, as you say, you
can only partially apply the functions IN ORDER.
Haskell has one sole exception to this: Binary operators can be curried
in any order. So (5/) and (/5) are both valid functions (and, you'll
notice, have different meanings).
If it's /really/ a problem, it's utterly trivial to write a tiny little
lambda function to set one of the arguments in the middle of the
argument list. Currying is just a handy short-cut in that instance.
As I say, the only "really powerful" thing about currying is the ability
to polymorphically handle multi-argument functions. Other than that,
it's just a handy short-cut.
Post a reply to this message
|
![](/i/fill.gif) |