[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: It's not currying!




Stephan,

> Stephan wrote:

...

> I have a very simple problem with this SRFI:
> the name is wrong. What is described is
> not currying (that much is admitted in
> the draft itself!)

...

> What *is* described is partial application.
> Now it so happens that if
> 1. multiple-argument functions are really
>    curried, single-argument functions, and
> 2. all evaluation is lazy,
> then there is no semantic difference between
> partial application on the first argument and
> full application. So one gets partial application
> "for free".

...


Indeed, the macro 'curry' provides only partial
application, and this is clearly stated in the
SRFI-document:

       "The mechanism proposed here is in fact only a
specialization of parameters. It does not really do
currying in the sense of constructing a procedure in

one argument that returns a procedure in one argument

and so on."


So, let me briefly explain why I have nevertheless

proposed a certain name for "a macro that does not

do currying":

       In the first place, currying is a very important

theoretical device because it reduces multiple-argument

functions to single-argument functions only (Schoenfinkel,

1924). Moreover, as you point out quite correctly,
programming languages in which functions are inherently

curried can provide a notation for partial application

on the first argument "for free". Scheme, on the other

hand is not curried, in the sense that functions are

inherently multiple-argument, and hence does not provide

any compact notation for partial application.

       Even worse, Scheme is not prepared to deal with
nested single-argument functions. For example, there is

no function to apply several arguments to such a curried

function. Moreover, there is no way at all to deal with

variable-arity functions---which have proven quite a
useful feature of Scheme after all.


Hence, the usual concept of currying a multiple-argument

function into a nesting of lambda-_expression_ (although

possible) is of very limited use in Scheme. In fact,

it facilitates programming less than one might expect.


After this observation, I concluded that an efficient

notation for partial evaluation might be as good as

it gets when it comes to currying in Scheme. In fact,

partial application does what you want to achieve with

currying in other languages. (There is another aspect

related to typing, though.)


Because of this I saw (and still see) little harm in

calling the macro for partial application 'curry'.

Obviously, this point of view is not always shared

as several people have already complained about it.


As I do not put too much emphasis on the name of the

macro, as long as it is specific and intuitive, I

would like to propose the name


       partial-apply


and offer to rewrite the SRFI-document accordingly.

This includes a better explanation of what the difference

and relation is between currying and partial application.


Does this resolve you problem with the name?


Sebastian.