Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Christopher L Conway <cconway@c...>
Subject: Re: [Caml-list] log function without evaluate arguments
If you're using OCaml version <= 3.09, check out pa_log
(http://www.cs.nyu.edu/~cconway/tools/index.html). I wrote it for
exactly this purpose.

Even if you're using 3.10, you might want to check it out. It's a
really simple extension and updating it might be a good excuse to
learn the new camlp4.

Regards,
Chris

On 11/6/07, tmp123 <tmp123@menta.net> wrote:
> 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.
>
> If my understanting of the reading has been correct, one of the best
> options seems to be something like (in camlp4r revised syntax, I'm more
> used to it):
>
> value log_flag = ref False;
>
> value log e =
>   if log_flag.val
>   then
>     Lazy.force e
>   else ();
>
> and the callers must include lines like:
>
> log (lazy (Printf.printf "%d" (sum 1 3)));
>
> Please, is this a good way? Some sugestions to made it better in
> performance or syntax?
>
> Thanks a lot.
>
>
>
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>