Browse thread
log function without evaluate arguments
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Till Varoquaux <till.varoquaux@g...> |
| Subject: | Re: [Caml-list] log function without evaluate arguments |
On 11/6/07, Nicolas Pouillard <nicolas.pouillard@gmail.com> wrote: > 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. > > Regards, > Actually it doesn't: log (lazy (Printf.printf "%s" (awfully_long_computation ()))) when log_val is false (or sylvain's solution, which I prefer), will not behave like Printf.ifprinf "%s" (awfully_long_computation ()) (it won't evaluate its arguments). Till -- http://till-varoquaux.blogspot.com/