Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] partial eval question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-02-04 (03:00)
From: Walid Taha <taha@c...>
Subject: Re: [Caml-list] partial eval question

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 <int N>
|inline double pow (double x) {
|  return x * pow<N-1>(x);
|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:

(Comments are welcome, actually, the paper is undergoing the final 

|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<any constant>.
|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.


|To unsubscribe, mail Archives:
|Bug reports: FAQ:
|Beginner's list:


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: