Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: -- (:)
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
> of

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

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: