[erlang-questions] will Erlang ever have currying?

Robert Smart robert.kenneth.smart@REDACTED
Wed Sep 6 02:22:33 CEST 2006


> F = fun(A,B) -> A+B end.
> F1 = F(2).

As long as a language does closures right (erlang does) and
has a notation for anonymous functions (erlang does) then we
can do currying:

  F1 = fun(X) -> F(2,X) end.

Which works whichever parameter we want to fix. Traditional
left to right currying only makes sense for those languages
where functional application is written (f a b) which actually
means ((f a) b). Half the time the first parameter isn't the one
you want to fix.

Perl6 has kitchen sink currying. I doubt if we want to go
there. You can do currying in scala if you define the function
that way (http://scala.epfl.ch/intro/currying.html). But we
can do that in erlang:

  F = fun(A) -> fun(B) -> A+B end end.

The real problem is the heavyweight nature of the anonymous
function syntax. Also the compilers might not be optimal for
this mode of operation which is not normal erlang style.

If we're going to fix syntax then having a nice way of
handling hashes/dictionaries/namespaces is more important.

Bob



More information about the erlang-questions mailing list