Browse thread
The universal variable 'a would escape its scope
- Christophe TROESTLER
[
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: | 2005-01-05 (18:15) |
From: | Christophe TROESTLER <Christophe.Troestler@u...> |
Subject: | The universal variable 'a would escape its scope |
Hi, I got a variant of the error http://caml.inria.fr/archives/200207/msg00110.html and I do not understand it. Here is a small example showing it: # type 'a t = < output : (string -> unit) -> unit; .. > as 'a;; type 'a t = 'a constraint 'a = < output : (string -> unit) -> unit; .. > # class a = object method f : 'a. 'a t -> unit = fun o -> o#output print_string end;; method f : 'a. 'a t -> unit = fun o -> o#output print_string ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This expression has type < output : (string -> unit) -> unit; .. > but is here used with type < output : (string -> unit) -> unit; .. > The universal variable 'a would escape its scope If I do something with ['a list] instead of ['a t] (or if ['a t] is abstract), I got no problem. If [f] is a function instead of a method, it works. (I do _not_ want to have to coerce the object passed to [f].) Is there something one can do about this? Cheers, ChriS