Browse thread
[Caml-list] kprintf with user formatters
[
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: | 2004-07-15 (12:19) |
From: | Markus Mottl <markus@o...> |
Subject: | Re: [Caml-list] kprintf with user formatters |
On Thu, 15 Jul 2004, Damien wrote: > I had the same problem a month ago, > I ended with the following ugly function: > > let log b fmt = > if b then Printf.printf fmt > else > let rec f x = Obj.magic f in > f fmt > (* val f: bool -> ('a, out_channel, unit) format -> 'a *) > > (I think this is safe since f just eats its arguments, > and gets typed with "-rectypes" : ('b->'a) as 'a) > > maybe a function "zprintf" could be added to Printf and Format to do > this job ? Thanks for the hint, this works for me! I also think that there should be some kind of "zprintf"-function in the standard library. Forcing people to use "-rectypes" or "Obj.magic" is evil. Regards, Markus -- Markus Mottl http://www.oefai.at/~markus markus@oefai.at ------------------- 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