From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p0ALN6sN000771 for ; Mon, 10 Jan 2011 22:23:07 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiQBAIMHK02CcYARmWdsb2JhbACWO44lAQEBAQEICwoHESS7VYVMBIRniUM X-IronPort-AV: E=Sophos;i="4.60,303,1291590000"; d="scan'208";a="94970665" Received: from coriana6.cis.mcmaster.ca ([130.113.128.17]) by mail1-smtp-roc.national.inria.fr with ESMTP; 10 Jan 2011 22:23:00 +0100 Received: from Dura7.UTS.McMaster.CA (dura7.UTS.McMaster.CA [130.113.196.62]) by coriana6.cis.mcmaster.ca (8.13.7/8.13.7) with ESMTP id p0ALMpcq015181; Mon, 10 Jan 2011 16:22:58 -0500 (EST) Received: from cgpsrv2.cis.mcmaster.ca (univmail.CIS.mcmaster.ca [130.113.64.46]) by Dura7.UTS.McMaster.CA (8.13.7/8.13.7) with ESMTP id p0ALMLpd013196; Mon, 10 Jan 2011 16:22:21 -0500 Received: from [173.32.159.3] (account carette@univmail.cis.mcmaster.ca HELO [192.168.2.100]) by cgpsrv2.cis.mcmaster.ca (CommuniGate Pro SMTP 5.2.12) with ESMTPSA id 336795589; Mon, 10 Jan 2011 16:22:21 -0500 Message-ID: <4D2B7893.5030802@mcmaster.ca> Date: Mon, 10 Jan 2011 16:22:27 -0500 From: Jacques Carette Organization: McMaster University User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 MIME-Version: 1.0 To: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-PMX-Version-Mac: 5.6.0.2009776, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2011.1.10.210917 X-PerlMx-Spam: Gauge=IIIIIIII, Probability=8%, Report=' BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_1200_1299 0, BODY_SIZE_2000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MOZILLA_MSGID 0, __SANE_MSGID 0, __TO_NO_NAME 0, __USER_AGENT 0' X-Spam-Flag: NO Subject: [Caml-list] Can this be inlined? I am experimenting with some fairly generic traversal code (over a complex AST), but am a little scared that the result will be horribly inefficient. I have been trying (with -dlambda and -dcmm, but not reading the .s output from using -S) to experiment with this myself, unsuccessfully. Here is a very simplified setup type ('a,'b) t = A | B of 'a * ('a,'b) t | C of 'b * ('a, 'b) t type ('a, 'b) ff = { a: ('a -> 'a) option; b : ('b -> 'b) option } let oapply optf x = match optf with Some f -> f x | None -> x let id x = x 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? Jacques