You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 4091 Reporter: Christoph Bauer Status: closed (set by @damiendoligez on 2006-08-29T14:29:58Z) Resolution: not a bug Priority: normal Severity: minor Version: 3.09.2 Category: ~DO NOT USE (was: OCaml general)
Bug description
Here is an example for an Bug.
It should write the string "hello" in a file but raises an error.
Objective Caml version 3.09.2
(* Helper function *)
let with_out_channel filename f =
let ch = open_out filename in
try
let result = f ch in
close_out ch;
result
with exc ->
close_out ch;
raise exc ;;
val with_out_channel : string -> (out_channel -> 'a) -> 'a =
(* f should do the hard work *)
let f ch s = output_string ch s;;
val f : out_channel -> string -> unit =
(* checking the type *)
with_out_channel "/tmp/t.txt" f;;
: string -> unit =
(* looks good. apply *)
with_out_channel "/tmp/t.txt" f "test";;
Exception: Sys_error "Bad file descriptor".
(* working workaround *)
with_out_channel "/tmp/t.txt" (fun ch -> f ch "test");;
: unit = ()
The text was updated successfully, but these errors were encountered:
Original bug ID: 4091
Reporter: Christoph Bauer
Status: closed (set by @damiendoligez on 2006-08-29T14:29:58Z)
Resolution: not a bug
Priority: normal
Severity: minor
Version: 3.09.2
Category: ~DO NOT USE (was: OCaml general)
Bug description
Here is an example for an Bug.
It should write the string "hello" in a file but raises an error.
Objective Caml version 3.09.2
(* Helper function *)
let with_out_channel filename f =
val with_out_channel : string -> (out_channel -> 'a) -> 'a =
(* f should do the hard work *)
let f ch s = output_string ch s;;
val f : out_channel -> string -> unit =
(* checking the type *)
with_out_channel "/tmp/t.txt" f;;
(* looks good. apply *)
with_out_channel "/tmp/t.txt" f "test";;
Exception: Sys_error "Bad file descriptor".
(* working workaround *)
with_out_channel "/tmp/t.txt" (fun ch -> f ch "test");;
The text was updated successfully, but these errors were encountered: