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 EAA02013; Wed, 4 Feb 2004 04:00:08 +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 EAA01386 for ; Wed, 4 Feb 2004 04:00:06 +0100 (MET) Received: from cs.rice.edu (cs.rice.edu [128.42.1.30]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id i14305P04195 for ; Wed, 4 Feb 2004 04:00:06 +0100 (MET) Received: from localhost (localhost [127.0.0.1]) by cs.rice.edu (Postfix) with ESMTP id BE2534AAF6; Tue, 3 Feb 2004 21:00:04 -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 06910-01-12; Tue, 3 Feb 2004 21:00:01 -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 AD15D4AAFD; Tue, 3 Feb 2004 20:59:57 -0600 (CST) Date: Tue, 3 Feb 2004 20:59:57 -0600 (CST) From: Walid Taha To: Andrew Lenharth Cc: William Chesters , Subject: Re: [Caml-list] partial eval question In-Reply-To: <20031027185021.GA1793@vilya.homelinux.net> 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 keywork:01 well-typed:01 bug:01 faq:01 faq:01 beginner's:01 beginners:01 bin:01 compiler:01 caml-bugs:01 ocaml:01 caml:01 caml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, 27 Oct 2003, Andrew Lenharth wrote: |On Mon, Oct 27, 2003 at 03:39:21PM +0000, William Chesters wrote: |> 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.) | |And that's an improvement over | |template |inline double pow (double x) { | return x * pow(x); |} |template<> |inline double pow<0> (double x) { | return 1.0; |} | |in what way exactly? (If it doesn't work for you, try |-O2) :) OK. There is an article specifically about this point: http://www.cs.rice.edu/~taha/publications/preprints/2003-12-01.pdf (Comments are welcome, actually, the paper is undergoing the final revision). |The C example relies on a fairly smart compiler to |do interprocedual analysis. The C++ example |only requires the inline keywork be honored, and you |don't need explicit pow3 pow2, you have pow<3> pow<2> |pow. | |Gives a bit more control over code generation. The draw back with C++ templates, in this case, is that you have to wait until the C++ code is generate before you know it type checks. A key goal of MSP is to ensure that generated code is *always* well-typed. That actually has been achieved in the context of a wide-range of type systems. Walid. |Andrew | |------------------- |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 | -- ------------------- 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