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: | -- (:) |
| From: | Basile Starynkevitch [local] <basile.starynkevitch@i...> |
| Subject: | Re: [Caml-list] kprintf with user formatters |
On Thu, Jul 15, 2004 at 02:19:47PM +0200, Markus Mottl wrote:
> 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 ?
I don't understand what this zprintf function should be, but the above
log proposal behave strangely (and perhaps unsafely) :
# log false "a=%d s=%S\n%!" 1 "xyz";;
- : unit = <unknown constructor>
For what it's worth, long time ago, I ended writing a camlp4 extension
for a similar logging (or tracing purpose) see file README.trace and
pa_trace.ml of
http://cvs.sourceforge.net/viewcvs.py/poesia/PoesiaSoft/PoesiaMonIcap/
Regards.
--
Basile STARYNKEVITCH -- basile dot starynkevitch at inria dot fr
Project cristal.inria.fr - phone +33 1 3963 5197 - mobile 6 8501 2359
http://cristal.inria.fr/~starynke --- all opinions are only mine
-------------------
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