Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Christopher L Conway" <cconway@cs.nyu.edu>
To: caml-list@inria.fr
Subject: Re: [Caml-list] log function without evaluate arguments
Date: Tue, 6 Nov 2007 22:40:44 -0500	[thread overview]
Message-ID: <4a051d930711061940ubf4aa40r6e41c54b910c5214@mail.gmail.com> (raw)
In-Reply-To: <47309EEC.4080706@menta.net>

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
>
>


  parent reply	other threads:[~2007-11-07  3:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-06 17:05 tmp123
2007-11-06 16:57 ` Sylvain Le Gall
2007-11-06 18:25 ` [Caml-list] " Nicolas Pouillard
2007-11-06 18:40   ` Till Varoquaux
2007-11-06 18:49     ` Brian Hurt
2007-11-07  3:39       ` Christopher L Conway
2007-11-07  4:00         ` Erik de Castro Lopo
2007-11-07  4:10           ` Christopher L Conway
2007-11-07 13:42             ` Brian Hurt
2007-11-07 10:21     ` Nicolas Pouillard
2007-11-07  3:40 ` Christopher L Conway [this message]
     [not found] ` <4a051d930711061938u25836a85ud28c610312e5896f@mail.gmail.com>
2007-11-07 10:31   ` tmp123

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4a051d930711061940ubf4aa40r6e41c54b910c5214@mail.gmail.com \
    --to=cconway@cs.nyu.edu \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox