From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 1D0D4BC0B for ; Mon, 27 Nov 2006 13:00:26 +0100 (CET) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.231]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id kARC0PHt009842 for ; Mon, 27 Nov 2006 13:00:25 +0100 Received: by wx-out-0506.google.com with SMTP id h26so1681070wxd for ; Mon, 27 Nov 2006 04:00:25 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=loqgGXu/NPV2eNOf/Pc35ud7LFYPw/CiF7JI2PHGsal8FdnAPIYHUgITqpt4RCSPCP/0SVqvJSnEeqXZP6oWXamAcIYwu5fqUffVVWmYF3oKA96G3CfhVVm2MzTgSlwyzIULJDE0FsyK1rGFsqkpnH0VDkz0XZk1+YKk+wc1G7k= Received: by 10.90.56.14 with SMTP id e14mr9739027aga.1164628824662; Mon, 27 Nov 2006 04:00:24 -0800 (PST) Received: by 10.90.114.12 with HTTP; Mon, 27 Nov 2006 04:00:24 -0800 (PST) Message-ID: <90823c940611270400m475c922fs6020fa2e47cf1e0a@mail.gmail.com> Date: Mon, 27 Nov 2006 15:00:24 +0300 From: "Dmitry Bely" To: caml-list@inria.fr Subject: Re: [Caml-list] optimizing trivial functions In-Reply-To: <8701A805-C71D-4CC0-BAE1-7EFEF5D50B61@cmu.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <6BDD3772-05B7-41DD-B36C-B2CBB0D4B388@cmu.edu> <8701A805-C71D-4CC0-BAE1-7EFEF5D50B61@cmu.edu> X-j-chkmail-Score: MSGID : 456AD359.000 on discorde : j-chkmail score : X : 0/20 1 X-Miltered: at discorde with ID 456AD359.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; trivial:01 ocaml:01 compiler:01 ocamlopt:01 debugging:01 wrote:01 caml-list:01 caml-list:01 functions:01 dmitry:01 dmitry:01 int:01 bely:01 bely:01 caml:02 On 11/26/06, Sean McLaughlin 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