Commits

camlspotter committed ec6fd70

added with_oc

  • Participants
  • Parent commits 627a015

Comments (0)

Files changed (2)

   let back_v = !r in
   r := v;
   Exn.protect ~f () ~finally:(fun () -> r := back_v)
+    
+
+let with_oc oc f = 
+  Exn.protect' (fun () -> f oc) ~finally:(fun () -> close_out oc)
     raises an exceptoin.
 *)
 
+(** {6 I/O } *)
+
+val with_oc : out_channel -> (out_channel -> 'a) -> 'a
+
 (** {6 Misc things } *)
 
 val sprintf : ('a, unit, string) format -> 'a
 
 val time : ('a -> 'b) -> 'a -> 'b * float
 (** simple profiling *)
+