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-16 (06:18)
From: Pierre Weis <pierre.weis@i...>
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
> it.
> > 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.

That's the debugger view of the problem :)

The Caml compiler's view is simpler: you broke the type system, you
get wrong results!

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

I have no time to try and find a way to get a bus error with that one
but I would not be glad to use software based on such a ugly hack that
is not proved harmless in any case.

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

``the application is a server which should run permanently'' ? Wao!
May I suggest no to use Obj.magic too often for this kind of
application ? Especially when you ``don't think that this hack will
be too dangerous'': this hack could kill your server not too permanently!

Best 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