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
log function without evaluate arguments
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-11-06 (18:25)
From: Nicolas Pouillard <nicolas.pouillard@g...>
Subject: Re: [Caml-list] log function without evaluate arguments
Excerpts from tmp123's message of Tue Nov 06 18:05:48 +0100 2007:
> Hello,
> In order to implement a function that prints log messages only, by
> example, if a boolean flag is true, and does nothing elsewhere, I've
> been reading the (long) post sequence "kprintf with user formatters"
> (2004 Jun 30).
> In this context, "does nothing" means not convert parameters to text nor
> evaluate them.

Have a look to the Printf.ifprintf [1] function, it does exactly what you want.


val ifprintf : 'a -> ('b, 'a, unit) format -> 'b
(** Same as {!Printf.fprintf}, but does not print anything.
    Useful to ignore some material when conditionally printing. *)

Nicolas Pouillard aka Ertai