[
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: | Didier Le Botlan <lebotlan@b...> |
| Subject: | Re: [Caml-list] Unbound type variables |
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