Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Dmitry Bely" <dmitry.bely@gmail.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] optimizing trivial functions
Date: Mon, 27 Nov 2006 15:00:24 +0300	[thread overview]
Message-ID: <90823c940611270400m475c922fs6020fa2e47cf1e0a@mail.gmail.com> (raw)
In-Reply-To: <8701A805-C71D-4CC0-BAE1-7EFEF5D50B61@cmu.edu>

On 11/26/06, Sean McLaughlin <seanmcl@cmu.edu> wrote:

> >   Will the Ocaml compiler optimize the following code to let y = ()?
> > I'm designing a program that will depend heavily on whether this code
> > is optimized in this way.
> >
> > let f x1 x2 ... x100 = ()
> > let y = f x1 ... x100

Yes, ocamlopt can do that.

> To answer my own question, of course it can't do that, because the
> arguments could have side effects.
>
> f (print_int 5) ...

So what? The arguments will be evaluated but the function call will be
optimized away.

I guess you are trying to implement some debugging that can be
switched off in the release version? If so, the following might be
interesting for you:

http://caml.inria.fr/pub/ml-archives/caml-list/2003/09/f2bf1cc8545d5e073638bd70d02b5056.en.html

- Dmitry Bely


      reply	other threads:[~2006-11-27 12:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-21 23:20 Sean McLaughlin
2006-11-26 13:36 ` [Caml-list] " Sean McLaughlin
2006-11-27 12:00   ` Dmitry Bely [this message]

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=90823c940611270400m475c922fs6020fa2e47cf1e0a@mail.gmail.com \
    --to=dmitry.bely@gmail.com \
    --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