Re: arity of type constructors

From: Damien Doligez (
Date: Fri May 09 1997 - 13:53:15 MET DST

Date: Fri, 9 May 1997 13:53:15 +0200
From: Damien Doligez <>
Message-Id: <>
Subject: Re: arity of type constructors

>Applying T to x does not work, but applying it to (3,4) does. Why is
>the pair (3,4) counted as 2 arguments?

Constructors have an arity. Here, T expects two arguments. When you
write T(3,4), you're not applying T to a pair, but applying T to two
arguments, 3 and 4. It happens that the syntax looks like a pair, but
this is more a misfeature of the syntax than anything else.

The alternative is to make all constructors take one argument, and use
a pair as argument when you want two arguments. This approach is
harder to implement and it makes it possible to write horribly
obfuscated code. Moreover, the pair has to be something special. In
the current system, the pair is just another binary constructor.

We have tried both approaches in Caml Light, and I really think the
current one is the right one.

En Francais:

Les constructeurs ont une arite. Quand on ecrit T(3,4), on n'applique
pas T a la paire (3,4), comme la syntaxe pourrait le faire croire,
mais on applique T a deux arguments, 3 et 4.

-- Damien

This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:10 MET