From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA04047; Mon, 27 Oct 2003 16:37:36 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA07533 for ; Mon, 27 Oct 2003 16:37:35 +0100 (MET) Received: from gadolinium.btinternet.com (gadolinium.btinternet.com [194.73.73.111]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h9RFbY120121 for ; Mon, 27 Oct 2003 16:37:34 +0100 (MET) Received: from host81-128-61-136.in-addr.btopenworld.com ([81.128.61.136] helo=beertje.william.bogus) by gadolinium.btinternet.com with esmtp (Exim 3.22 #23) id 1AE9Qy-0005R6-00; Mon, 27 Oct 2003 15:37:32 +0000 Received: by beertje.william.bogus (Postfix, from userid 501) id B33B085661; Mon, 27 Oct 2003 15:39:21 +0000 (GMT) From: William Chesters MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16285.15401.421786.814601@beertje.william.bogus> Date: Mon, 27 Oct 2003 15:39:21 +0000 To: Subject: Re: [Caml-list] partial eval question In-Reply-To: <20031027081453.37b9f6ee.Damien.Pous@ens-lyon.fr> References: <004a01c39c2b$819db8f0$1fcf2952@Archimedes> <20031027081453.37b9f6ee.Damien.Pous@ens-lyon.fr> X-Mailer: VM 7.04 under 21.4 (patch 8) "Honest Recruiter" XEmacs Lucid X-Loop: caml-list@inria.fr X-Spam: no; 0.00; chesters:01 williamc:01 paneris:01 caml-list:01 damien:01 multi-stage:01 metaocaml:01 metaocaml:01 metaml:01 metaml:01 multi-stage:01 error-prone:01 inlining:01 unrolling:01 compilers:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Damien writes: > Multi-Stage Programming is your friend... > > > There are two ML implementations : > Ocaml : MetaOCaml > SML : MetaML > > > let rec pow n = .< > .~(match n with > | 1 -> .< fun x -> x >. > | n -> .< fun x -> x * .~(pow (n-1)) x>. > ) > >. > > (pow 3) get reduced into . x*x*x>. And that's an improvement over double pow(double x, int n) { double it = 1; while (--n >= 0) it *= x; return it; } double pow3(double x, int n) { return pow(x, 3); } in what way exactly? (If it doesn't work for you, try -funroll-all-loops.) For these kinds of purposes, Multi-Stage Programming is a very labour-intensive and error-prone way of doing what mainstream compilers will do for you already. Maybe it has useful applications in e.g. generation of numerical codes, where inlining, unrolling, "templatization" and partial evaluation are not enough because major structural transformations are required. But then, maybe sophisticated jobs like that are always going to be easiest done with special-purpose code generators? ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners