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

 From: Eli Barzilay (eli at barzilay.org) Date: Wed Dec 31 18:54:02 EST 2008 Previous message: [plt-scheme] Why do layman programmers care about Currying? Next message: [plt-scheme] Why do layman programmers care about Currying? Messages sorted by: [date] [thread] [subject] [author]

```On Thu, Jan 1, 2009 at 1:42 AM, Joe Marshall <jmarshall at alum.mit.edu> wrote:
> On Wed, Dec 31, 2008 at 3:18 PM, Matthias Felleisen
> <matthias at ccs.neu.edu> wrote:
>>
>> You could imagine a world that looks like this:
>>
>> (define (f #:a (a #f) #:b (b #f) #:c (c #f))
>>  (cond
>>    [(and a b c) (fcore a b c)]
>>    [(and a b) (lambda (c) (fcore a b c))]
>>    [(and a c) (lambda (b) (fcore a b c))]
>>    [(and b c) (lambda (a) (fcore a b c))]
>>    [a (lambda (b c) (fcore a b c))]
>>    [b (lambda (a c) (fcore a b c))]
>>    [c (lambda (a b) (fcore a b c))]))
>>
>> ((f #:a 0) 1 2)
>> ((f #:a 0 #:c 2) 1)
>> ..
>>
>> John Lamping explored this form of abstraction in his dissertation and I
>> always thought there was something neat about it.
>
> I played around with this sort of thing years ago, but the thing I didn't
> like was that it is really hard to figure out what (f #:a 0) means.
> It's a function
> of `the rest of the arguments', but you have to know the ultimate function
> fcore to figure out what arguments (and it what order) to call it.  This isn't
> much of a problem until you start defining higher order functions and then
> you get a real mess of keyword soup.  (And you would want some sort of
> `subtractive' mechanism to *omit* arguments previously provided.)

You mean that (f #:a 0) is a function that will reject further uses of
`#:a'?  It sounds doable, though probably easier to write some generic
facility to do so which will use the primitive keyword application
functionality (ie, fixing Matthias's code is going to be very
verbose).  Also, IIRC, that's exactly what you get with keyworded
arguments in Ocaml -- and things are even easier when you have a type
system that can do that subtraction.

--
((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
http://www.barzilay.org/                 Maze is Life!

```

 Posted on the users mailing list. Previous message: [plt-scheme] Why do layman programmers care about Currying? Next message: [plt-scheme] Why do layman programmers care about Currying? Messages sorted by: [date] [thread] [subject] [author]