Version française
Home     About     Download     Resources     Contact us    
Browse thread
The universal variable 'a would escape its scope
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christophe TROESTLER <Christophe.Troestler@u...>
Subject: Re: [Caml-list] The universal variable 'a would escape its scope
On Thu, 06 Jan 2005, Jacques Garrigue <garrigue@math.nagoya-u.ac.jp> wrote:
> 
> The workaround is to use a class-type:
> 
> # class type t = object method output : (string -> unit) -> unit end;;
> class type t = object method output : (string -> unit) -> unit end
> # class a = object
>     method f : 'a. (#t as 'a) -> unit = fun o -> o#output print_string
>   end;;
> class a : object method f : #t -> unit end
> 
> This does exactly what you want.

Thanks,
ChriS