Functional programming in Python

Manuel M. T. Chakravarty chak@cse.unsw.edu.au
Tue, 22 May 2001 23:54:48 +1000


Pertti Kellom=E4ki <pk@cs.tut.fi> wrote,

> > From: Ketil Malde <ketil@ii.uib.no>
> > "Manuel M. T. Chakravarty" <chak@cse.unsw.edu.au> writes:
> > > You want to be able to write
> > =

> > >   f 1 2 + g 3 4
> > =

> > > instead of
> > =

> > >   (f 1 2) + (g 3 4)
> > =

> > I do?  Personally, I find it a bit confusing, and I still often get =
it
> > wrong on the first attempt. =

> =

> Same here. A while back someone said something along the lines that pe=
ople
> come to Haskell because of the syntax. For me it is the other way arou=
nd.
> My background is in Scheme/Lisp, and I still find it irritating that I=
 cannot
> just say indent-sexp and the like in Emacs. It is the other properties=
 of the
> language that keep me using it. I also get irritated when I get
> precedence wrong, so in fact I tend to write (f 1 2) + (g 2 3), which =
to
> my eye conveys the intended structure much better and compiles at firs=
t try.

In languages that don't use curring, you would write =


  f (1, 2) + g (2, 3) =


which also gives application precedence over infix
operators.  So, I think, we can safely say that application
being stronger than infix operators is the standard
situation.

Nevertheless, the currying notation is a matter of habit.
It took me a while to get used to it, too (as did layout).
But now, I wouldn't want to miss them anymore.  And as far
as layout is concerned, I think, the Python people have made
the same experience.  For humans, it is quite natural to use
visual cues (like layout) to indicate semantics.

Cheers,
Manuel