Browse thread
[Caml-list] kprintf with user formatters
-
Damien
-
Pierre Weis
- Markus Mottl
-
Pierre Weis
[
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: | henri dubois-ferriere <henridf@g...> |
| Subject: | Re: [Caml-list] kprintf with user formatters |
any idea how this would compare (performance-wise) to building a closure
(fun () -> printf ...) , and then evaluating the closure only when
the debug level is ok?
henri
On Thu, 15 Jul 2004 09:59:45 +0200, Jean-Christophe Filliatre
<jean-christophe.filliatre@lri.fr> wrote:
>
> David MENTRE writes:
> >
> > > If the given log level "level" does not allow logging the message
> > > specified by "fmt", I just want to ignore the parameters provided together
> > > with "fmt" - but how?
> >
> > # let cur_level = ref 0;;
> > val cur_level : int ref = {contents = 0}
> > # let log level fmt =
> > let print_at_level str = if !cur_level >= level then print_string str in
> > Format.kprintf print_at_level fmt;;
> > val log : int -> ('a, unit, string, unit) format4 -> 'a = <fun>
>
> This solution still has the drawback of evaluating the whole message
> (which can be costly).
>
> Damien Pous's post has the expected behavior (printf arguments are
> simply discarded without any evaluation) but requires Obj.magic...
>
> --
> Jean-Christophe
>
>
>
> -------------------
> 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
>
-------------------
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