Browse thread
[Caml-list] Unbound type variables
-
Patrick M Doane
- Olivier Andrieu
-
Didier Le Botlan
- Patrick M Doane
[
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: | 2001-09-13 (17:40) |
From: | Patrick M Doane <patrick@w...> |
Subject: | Re: [Caml-list] Unbound type variables |
Interesting - thanks to you and Olivier for pointing this out! I wasn't aware of how to do this or what the 'constraint' aspect might be used for. Patrick On Thu, 13 Sep 2001, Didier Le Botlan wrote: > What do you think of a parameterized class ? > > class ['a] c = object > method m (x:'a) = > match x with > | `A -> () > | `B -> () > | `C -> () > end > > class [[< `A | `B | `C] as 'b] c : > object constraint 'b = 'b method m : 'b -> unit end > > Beware that the 'a parameter is freezed for each instance of the class, > that is you cannot call method m twice on the same object with > incompatible arguments. > > > -- > Didier Le Botlan > http://cristal.inria.fr/~lebotlan > ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr