Browse thread
Re: arity of type constructors
- Damien Doligez
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Damien Doligez <Damien.Doligez@i...> |
| 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