Newsgroups: comp.lang.lisp,comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!udel!gatech!howland.reston.ans.net!ix.netcom.com!netcom.com!NewsWatcher!user
From: vanmeule@acm.org (Andre van Meulebrouck)
Subject: Re: curried vs. tupled
Message-ID: <vanmeule-1903950110410001@192.0.2.1>
Sender: vanmeule@netcom11.netcom.com
Organization: nil
References: <3jplaj$61k@cantaloupe.srv.cs.cmu.edu> <hbaker-1103950901230001@192.0.2.1>
Date: Sun, 19 Mar 1995 08:10:41 GMT
Lines: 65
Xref: glinda.oz.cs.cmu.edu comp.lang.lisp:17118 comp.lang.scheme:12353

In article <hbaker-1103950901230001@192.0.2.1>, hbaker@netcom.com (Henry
Baker) wrote:

> I can't comment on ml, but there are times when I wish certain functions
> in Lisp were curried rather than tupled.  

I agree entirely.  This whole area of partial evaluation and currying
needs to be re-examined.

Due to tunnel vision, people that see conventional languages first, then
LISP; find LISP quite strange (at least at first).

Due to similar tunnel vision we find that concepts from lambda calculus
seem strange to LISPers.

For instance, when first introduced to currying there is a temptation to
think that it's a hassle born of the thriftiness of lambda calculus and
that it's just a slower, less efficient way of dealing with parameters
than passing as many as you like to a function straightaway.

But then you start to see the brilliance of currying and that you can
express any non-curried function as a curried function BUT NOT THE
REVERSE!!!

Truly it is a very powerful technique that views parameters as like the
talons of a cat:  they are tucked away until needed (so they don't get in
the way).

Another use of currying (beyond your examples) is in roll-your-own objects
a la Abelson and Sussman.

Currying gives a much more uniform way of having messages that have
varying numbers of arguments.

You break the message out from the arguments so you can have uniformity:

(lambda (message)
  (cond 
    ((eq? message 'foo) 
     (lambda (arg1 arg2) ...))
    ((eq? message 'fido)
     (lambda (arg1) ...)

etc..

then call them:

((object 'foo) arg1 arg2)
((object 'fido) arg1)

Imagine trying to do this without currying.  How inelegant.  Of course you
could use the variable arity stuff in Scheme, but then if you pass these
objects around a lot you have to futs with them (inefficient and
confusing).  I.e.:

(lambda (message . args)

would mean you'd have to do something inelegant to get around the list
structuring of the arguments using apply:  (apply message args).  This
would mean less uniformity in calling conventions for "resident" objects
vs. those that got passed around.

;;;;;;;;;;;;;;;;;;;;  Andre van Meulebrouck  ;;;;;;;;;;;;;;;;;;;;;
;;  e-mail:  vanmeule@acm.org     finger:  vanmeule@netcom.com  ;;
;;;;;  URL:  ftp://ftp.netcom.com/pub/va/vanmeule/home.html  ;;;;;
