English version
Accueil     Ŕ propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis ŕ jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml ŕ l'adresse ocaml.org.

Browse thread
[Caml-list] kprintf with user formatters
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-07-15 (13:45)
From: Markus Mottl <markus@o...>
Subject: Re: [Caml-list] kprintf with user formatters
On Thu, 15 Jul 2004, Basile Starynkevitch [local] wrote:
> I don't understand what this zprintf function should be,

It should parse the format string, and ignore format arguments following

> but the above
> log proposal behave strangely (and perhaps unsafely) : 
> # log false "a=%d s=%S\n%!" 1 "xyz";;
> - : unit = <unknown constructor>

The reason for this is that it returns a function and not a unit value.
Unless you parse the format string, there is no way you can know when
to stop eating arguments to return a value.

I don't think that this hack will be too dangerous.  You might get an
exception 'Invalid_argument "equal: functional value"' if you want to
compare those fancy unit-values, which is about the worst thing you
can achieve.  But who would want to compare unit-values anyway?

> 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/

The preprocessor is not good enough for me.  I would like to change
log levels at runtime, because the application is a server which should
run permanently.


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