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-19 (10:10)
From: Pierre Weis <pierre.weis@i...>
Subject: Re: [Caml-list] kprintf with user formatters
> > Moreover, this solution is general enough to accomodate threads,
> > side effects, or whatever.
> You always need mutexes if you want to prevent that your output gets
> messed up by multiple threads.

Using thunks, the mutex handling can be done into the log function
around the tunk call.

> > To me the (fun () -> ) additional verbosity is not so bad: it clearly
> > emphasizes that nothing at all is evaluated when logging is unnecessary.
> It's rather the other way round: people using format strings may get
> the wrong idea that arguments are not converted if there is no output.

They also can have the wrong idea that arguments are not evaluated
(since there is no need to convert them to string) which is wrong.

> I don't think it is necessary or even useful to introduce new keywords.

You are right in general, but in this case we have to deal with a
notion that should change the evaluation regime of some
expressions. This cannot be implemented without the help of the

> A customized, beautiful solution would be possible with camlp4, thunks
> solve the problem semantically, but look ugly,

That why I propose to use something similar to assert and lazy: to get
a simple way to express this semantics.

> and some support for a kind of zprintf would be ideal :-)

I'm afraid this would not solve the lazyness problem.


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