Version française
Home     About     Download     Resources     Contact us    
Browse thread
class and printf
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] class and printf
On Monday 30 October 2006 12:42, Anastasia Gornostaeva wrote:
> What I need to drink to compile it?
>
> class foo ch =
> object
>  method myprintf = Printf.fprintf ch
> end
>
> The compiler says
> The method myprintf has type ('a, out_channel, unit) format -> 'a where 'a
> is unbound

Bind 'a:

# class ['a] foo ch = object
    method f : ('a, out_channel, unit) format -> 'a = Printf.fprintf ch
  end;;
class ['a] foo :
  out_channel -> object method f : ('a, out_channel, unit) format -> 'a end

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists