<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/10/630a4b8fb712e5f64fd00f8517c2efb1"
  from="Andrew Lenharth &lt;andrewl@d...&gt;"
  author="Andrew Lenharth"
  date="2003-10-27T18:50:37"
  subject="Re: [Caml-list] partial eval question"
  prev="2003/10/cf9626118d4267b7e9547675ec7c8d3a"
  next="2003/10/4240dba8e9df9f12e8085e87299a5d53"
  prev-in-thread="2004/02/40c8a56a41ad341968457f98c05e781e"
  next-in-thread="2004/02/a16f564331f7ac87203f997832197d47"
  prev-thread="2003/10/8079542ef4415111bf59cd27c0f9ab57"
  next-thread="2003/10/7acd408e746382c8e686db8ca031c848"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] partial eval question">
<msg 
  url="2003/10/de29dc29683545ed76beb0400f4751ec"
  from="Ben Kavanagh &lt;kavabean@l...&gt;"
  author="Ben Kavanagh"
  date="2003-10-27T01:42:24"
  subject="[Caml-list] partial eval question">
<msg 
  url="2004/02/9135da4880860aff7ee6bd2862347f71"
  from="Walid Taha &lt;taha@c...&gt;"
  author="Walid Taha"
  date="2004-02-04T02:51:13"
  subject="Re: [Caml-list] partial eval question">
<msg 
  url="2004/02/c9aa99c7ce1da5f86ed1c84a68d5577b"
  from="Ben Kavanagh &lt;kavabean@l...&gt;"
  author="Ben Kavanagh"
  date="2004-02-04T10:27:05"
  subject="RE: [Caml-list] partial eval question">
</msg>
<msg 
  url="2004/02/ab28e6d5251dbb35de26f4800a7648dd"
  from="Ben Kavanagh &lt;kavabean@l...&gt;"
  author="Ben Kavanagh"
  date="2004-02-04T10:32:54"
  subject="RE: [Caml-list] partial eval question">
<msg 
  url="2004/02/3a9f4f3f0fb6f94213b4b497d4d87bae"
  from="Walid Taha &lt;taha@c...&gt;"
  author="Walid Taha"
  date="2004-02-05T21:12:38"
  subject="RE: [Caml-list] partial eval question">
</msg>
</msg>
</msg>
<msg 
  url="2003/10/42e4a058f34baa9bc4a7f09a01c2fb56"
  from="Damien &lt;Damien.Pous@e...&gt;"
  author="Damien"
  date="2003-10-27T07:12:59"
  subject="Re: [Caml-list] partial eval question">
<msg 
  url="2003/10/749531e3b7c66d1e814447e320033178"
  from="William Chesters &lt;williamc@p...&gt;"
  author="William Chesters"
  date="2003-10-27T15:37:36"
  subject="Re: [Caml-list] partial eval question">
<msg 
  url="2004/02/40c8a56a41ad341968457f98c05e781e"
  from="Walid Taha &lt;taha@c...&gt;"
  author="Walid Taha"
  date="2004-02-04T02:57:05"
  subject="Re: [Caml-list] partial eval question">
</msg>
<msg 
  url="2003/10/630a4b8fb712e5f64fd00f8517c2efb1"
  from="Andrew Lenharth &lt;andrewl@d...&gt;"
  author="Andrew Lenharth"
  date="2003-10-27T18:50:37"
  subject="Re: [Caml-list] partial eval question">
<msg 
  url="2004/02/a16f564331f7ac87203f997832197d47"
  from="Walid Taha &lt;taha@c...&gt;"
  author="Walid Taha"
  date="2004-02-04T03:00:08"
  subject="Re: [Caml-list] partial eval question">
<msg 
  url="2004/02/62aff25824ac1dc4ddf6439cc95b8e2c"
  from="Andrew Lenharth &lt;alenhart@c...&gt;"
  author="Andrew Lenharth"
  date="2004-02-04T06:23:08"
  subject="Re: [Caml-list] partial eval question">
<msg 
  url="2004/02/ab4a9a7eeb231ae65620cc62433710d4"
  from="Walid Taha &lt;taha@c...&gt;"
  author="Walid Taha"
  date="2004-02-05T21:29:51"
  subject="Re: [Caml-list] partial eval question">
</msg>
</msg>
</msg>
<msg 
  url="2003/10/4240dba8e9df9f12e8085e87299a5d53"
  from="William Chesters &lt;williamc@p...&gt;"
  author="William Chesters"
  date="2003-10-27T19:10:12"
  subject="Re: [Caml-list] partial eval question">
<msg 
  url="2003/10/5f2fdaad333177c7d6a2b21daa0be41d"
  from="Jacques Carette &lt;carette@m...&gt;"
  author="Jacques Carette"
  date="2003-10-27T20:08:39"
  subject="RE: [Caml-list] partial eval question">
<msg 
  url="2004/02/fbf18488391fa9746efc5d2a4bef8477"
  from="Walid Taha &lt;taha@c...&gt;"
  author="Walid Taha"
  date="2004-02-04T03:04:02"
  subject="RE: [Caml-list] partial eval question">
</msg>
</msg>
<msg 
  url="2003/10/c5624fb84802867145896d6186f42066"
  from="Andrew Lenharth &lt;andrewl@d...&gt;"
  author="Andrew Lenharth"
  date="2003-10-27T22:11:26"
  subject="Re: [Caml-list] partial eval question">
</msg>
</msg>
</msg>
<msg 
  url="2003/10/a7723a0e7c90bd6cbf8e4e5e50cc4401"
  from="Yann Regis-Gianas &lt;yann.regisgianas@f...&gt;"
  author="Yann Regis-Gianas"
  date="2003-10-27T19:18:48"
  subject="Re: [Caml-list] partial eval question">
<msg 
  url="2003/10/5b5b69bb4359248a36d2c5d540be38c3"
  from="William Chesters &lt;williamc@p...&gt;"
  author="William Chesters"
  date="2003-10-28T10:43:30"
  subject="Re: [Caml-list] partial eval question">
<msg 
  url="2004/02/861c8dd1fe70d0ffecfa0a33b820271e"
  from="Walid Taha &lt;taha@c...&gt;"
  author="Walid Taha"
  date="2004-02-04T02:22:58"
  subject="Re: [Caml-list] partial eval question">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2003/10/36fc484e0287ec54175420cdd6ec261b"
  from="Dmitry Lomov &lt;Dmitry.Lomov@i...&gt;"
  author="Dmitry Lomov"
  date="2003-10-28T15:17:02"
  subject="Re: [Caml-list] partial eval question">
</msg>
</msg>
<msg 
  url="2003/10/911861d0f0fa5c5495de5216bbf14cad"
  from="Vincent Balat [prof Moggi team] &lt;balat@d...&gt;"
  author="Vincent Balat [prof Moggi team]"
  date="2003-10-27T15:21:53"
  subject="Re: [Caml-list] partial eval question">
</msg>
</msg>
</thread>

<contents>
On Mon, Oct 27, 2003 at 03:39:21PM +0000, William Chesters wrote:
&gt; And that's an improvement over
&gt; 
&gt;     double pow(double x, int n) {
&gt;       double it = 1;
&gt;       while (--n &gt;= 0) it *= x;
&gt;       return it;
&gt;     }
&gt; 
&gt;     double pow3(double x, int n) {
&gt;       return pow(x, 3);
&gt;     }
&gt; 
&gt; in what way exactly?  (If it doesn't work for you, try
&gt; -funroll-all-loops.)

And that's an improvement over

template &lt;int N&gt;
inline double pow (double x) {
  return x * pow&lt;N-1&gt;(x);
}
template&lt;&gt;
inline double pow&lt;0&gt; (double x) {
  return 1.0;
}

in what way exactly?  (If it doesn't work for you, try 
-O2) :)

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&lt;3&gt; pow&lt;2&gt; 
pow&lt;any constant&gt;.

Gives a bit more control over code generation.

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

</contents>

</message>

