[
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: | -- (:) |
| From: | Pierre Weis <pierre.weis@i...> |
| Subject: | Re: [Caml-list] printf arguments |
> In trying to write a wrapper around printf for debug message logging,
> (a la syslog), I am coming across the following problem:
>
> # let myprintf fmt = if (true) then Printf.fprintf stdout fmt;;
> val myprintf : (unit, out_channel, unit) format -> unit = <fun>
If cond then expr == if cond then expr else ()
[...]
> so the myprintf function above does not have the same type as the original
> fprintf. Note that removing the if clause returns us to the proper type:
>
> # let myprintf fmt = Printf.fprintf stdout fmt;;
> val myprintf : ('a, out_channel, unit) format -> 'a = <fun>
If you want to preserve the original typing of printf, you must
imperatively use a tail call to printf (due to the typing discipline
of string format).
Regards,
Pierre Weis
INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners