From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p0ALVlkd001233 for ; Mon, 10 Jan 2011 22:31:47 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiQGAGIJK02ty1O7/2dsb2JhbACWO44Qc7tThUwEhGeJQw X-IronPort-AV: E=Sophos;i="4.60,303,1291590000"; d="scan'208";a="86470835" Received: from elehack.net ([173.203.83.187]) by mail2-smtp-roc.national.inria.fr with ESMTP; 10 Jan 2011 22:31:42 +0100 Received: from [134.84.75.86] (x-134-84-75-86.uofm-secure.wireless.umn.edu [134.84.75.86]) by elehack.net (Postfix) with ESMTPSA id 28FC4C8C92 for ; Mon, 10 Jan 2011 15:31:41 -0600 (CST) Message-ID: <4D2B7ABB.2080609@elehack.net> Date: Mon, 10 Jan 2011 15:31:39 -0600 From: Michael Ekstrand User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: caml-list@inria.fr References: <4D2B7893.5030802@mcmaster.ca> In-Reply-To: <4D2B7893.5030802@mcmaster.ca> X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] Can this be inlined? On 01/10/2011 03:22 PM, Jacques Carette wrote: > let rec trav f = function > | A -> A > | B (x,e) -> B (oapply f.a x, trav f e) > | C (x,e) -> C (oapply f.b x, trav f e) > > let t1 = {a=Some id; b=None} > > let tt x = trav t1 x > > I would like for 'tt' to contain a version of trav with no traces of > either oapply or t1 left. How can I achieve that? Is it possible? I > don't mind changing idioms (modules instead of record, etc), as long > as I can get my inlining to go through. [I also tried making oapply > and trav "local" to tt's definition, but that did not seem to make > much of a difference]. > > In any case, the real goal here is to see if I can safely adopt a > coding style like this, or do I need to manually do all the inlining > myself? I think that the problem is in the definition of 'trav' - it is both recursive and allocates memory. AFAIK, the OCaml compiler (at least the native code one) does not inline functions that are either recursive or allocate memory. So I think your only option - unless trav can be drastically rewritten - is to inline them yourself. - Michael