Browse thread
arity of type constructors
- Christian Lindig
[
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: | Christian Lindig <lindig@i...> |
| Subject: | arity of type constructors |
Dear Caml-Enthusiasts,
the following example of applying arguments to a new type constructor
was surprising for me. I'm wondering if it's a bug or a feature:
Objective Caml version 1.05
# type t = T of int * int;;
type t = | T of int * int
# let x = (3,4);;
val x : int * int = 3, 4
# T x;;
The constructor T expects 2 argument(s), but is here applied
to 1 argument(s)
# T (3,4);;
- : t = T (3, 4)
Applying T to x does not work, but applying it to (3,4) does. Why is
the pair (3,4) counted as 2 arguments?
Christian
[sorry, no french version - will visit Paris in summer as a compensation :-)]
------------------------------------------------------------------------------
Christian Lindig lindig@ips.cs.tu-bs.de
TU Braunschweig fon +49 531 391 7465
Institut fuer Programmiersprachen fax +49 531 391 8140
D-38106 Braunschweig http://www.cs.tu-bs.de