[Python-Dev] type categories

Guido van Rossum guido@python.org
Mon, 26 Aug 2002 15:26:34 -0400


> Indeed, ML completely unifies Cartesian product types and tuples in a
> very, very cool way:
> 
>       Every function takes exactly one argument
>       and yields exactly one result.
> 
>       However, the argument or result can be a tuple.
> 
> So in ML, when I write
> 
>       f(x,y)
> 
> that really means to bundle x and y into a tuple, and call f with that
> tuple as its argument.  So, for example, if I write
> 
>       val xy = (x,y)
> 
> which defines a variable named xy and binds it to the tuple (x,y), then
> 
>       f xy
> 
> means exactly the same thing as
> 
>       f(x,y)
> 
> The parentheses are really tuple constructors, and ML doesn't require
> parentheses for function calls at all.

ABC did this, and very early Python did this, too (but Python always
required parentheses for calls).  However, adding optional arguments
caused trouble: after

  def f(a, b=1):
      print a*b

  t = (1, 2)

what should

  f(t)

mean?  It could mean either f((1, 2), 1) or f(1, 2).  So we had to get
rid of that.  I suppose ML doesn't have optional arguments (in the
sense of Python), so the problem doesn't occur there; that's why it
wasn't a problem in ABC.

--Guido van Rossum (home page: http://www.python.org/~guido/)