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 DAA01403; Wed, 4 Feb 2004 03:57:05 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id DAA02109 for ; Wed, 4 Feb 2004 03:57:04 +0100 (MET) Received: from cs.rice.edu (cs.rice.edu [128.42.1.30]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id i142v3v24961 for ; Wed, 4 Feb 2004 03:57:03 +0100 (MET) Received: from localhost (localhost [127.0.0.1]) by cs.rice.edu (Postfix) with ESMTP id 97FC14AAF9; Tue, 3 Feb 2004 20:57:01 -0600 (CST) Received: from cs.rice.edu ([127.0.0.1]) by localhost (cs.rice.edu [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 05487-01-100; Tue, 3 Feb 2004 20:56:59 -0600 (CST) Received: from boromir.cs.rice.edu (boromir.cs.rice.edu [128.42.129.71]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by cs.rice.edu (Postfix) with ESMTP id 449754AAE9; Tue, 3 Feb 2004 20:56:59 -0600 (CST) Date: Tue, 3 Feb 2004 20:56:58 -0600 (CST) From: Walid Taha To: William Chesters Cc: caml-list@inria.fr Subject: Re: [Caml-list] partial eval question In-Reply-To: <16285.15401.421786.814601@beertje.william.bogus> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavis-20030616-p5 at rice.edu X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 chesters:01 damien:01 multi-stage:01 finer:01 unroll:01 runtime:01 compile-time:01 multi-stage:01 error-prone:01 labour:99 error-prone:01 inlining:01 unrolling:01 compilers:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, 27 Oct 2003, William Chesters wrote: |Damien writes: | > Multi-Stage Programming is your friend... | > | > | > 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.) Two reasons: 1) MSP is finer grained (you usually DON'T want to unroll all loops), and 2) you can do it at runtime (it's not limited to compile-time specialization). Those two simple reasons have a huge impact when you are building bigger and more complex software systems. |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. Why is MSP labour intensive? More importantly, why do you think it is error-prone? |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? What kinds do you have in mind? MSP's primary target users are indeed builders of code generators, but you seem to suggest that that somehow needs to be limited to an elite group of "generator writers"... That's exactly what MSP is supposed to help Joe Programmer avoid. Walid. ------------------- 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