[plt-scheme] Why do layman programmers care about Currying?

From: Richard Cleis (rcleis at mac.com)
Date: Thu Jan 1 10:21:13 EST 2009

On Dec 31, 2008, at 5:11 PM, Anthony Cowley wrote:

> On Wed, Dec 31, 2008 at 12:44 AM, Richard Cleis <rcleis at me.com> wrote:
>> However, I am not certain that Currying refers to reducing the  
>> arguments in
>> any order.  I have the impression that Currying literally means  
>> reducing
>> them in the order that they appear so that other functions may be  
>> written to
>> take advantage of such strictness.  Freeform reduction of arguments  
>> is
>> simply making use of closures.  No?
>> rac
> I've always found the ordering aspect mildly troubling. Currying
> transforms (a x b) -> c into a -> b -> c, but is (a x b) the same as
> (b x a)? Not normally for programmers, but if you justify Currying
> with the logical argument that (a /\ b) -> c <=> a -> b -> c, and you
> believe that conjunctions are commutative, then I'm not sure where
> that leaves you since you have identified product types with
> conjunctions. I think the safe bet is to just call it partial
> application and not have to worry about offending anyone :)
> For practical purposes, functions of fewer arguments are more common,
> so the flip function in Haskell's Prelude is commonly used when
> exploiting one's automatically curried functions. For example,
> Prelude> let f x y = x / y
> Prelude> let g = flip f 3
> Prelude> g 6
> 2.0
> I don't think there is a flip automatically in scope in SML/NJ, but
> it's a very handy function when working in this style as it handles
> the case of functions of two arguments where the arguments are
> "equally important." If your function takes more arguments, one
> technique is to order them in terms of heavyness, or import, and put
> the heavy ones first.

I often deal with functions of time, so program design involves  
deciding whether to make 'time' an argument of the higher level  
functions, or make 'time' an argument of each of the functions that  
are provided as arguments to those higher level functions. In other  
words, a single variable can affect the heaviness and ordering issues  
to which you refer.  To make best use of the fundamentals of a  
language, it seems necessary to invest resources in starting to  
develop independent solutions in order to reveal advantages. If I am  
wearing a programming hat, such parallel effort is enjoyable; if I am  
wearing a project managers hat, it's the reason that we are behind  
schedule :)

> Anthony
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.