<?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/4240dba8e9df9f12e8085e87299a5d53"
  from="William Chesters &lt;williamc@p...&gt;"
  author="William Chesters"
  date="2003-10-27T19:10:12"
  subject="Re: [Caml-list] partial eval question"
  prev="2003/10/630a4b8fb712e5f64fd00f8517c2efb1"
  next="2003/10/a7723a0e7c90bd6cbf8e4e5e50cc4401"
  prev-in-thread="2004/02/ab4a9a7eeb231ae65620cc62433710d4"
  next-in-thread="2003/10/5f2fdaad333177c7d6a2b21daa0be41d"
  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>
Andrew Lenharth writes:
 &gt; And that's an improvement over
 &gt; 
 &gt; template &lt;int N&gt;
 &gt; inline double pow (double x) {
 &gt;   return x * pow&lt;N-1&gt;(x);
 &gt; }
 &gt; template&lt;&gt;
 &gt; inline double pow&lt;0&gt; (double x) {
 &gt;   return 1.0;
 &gt; }
 &gt; 
 &gt; in what way exactly?

What I wrote, the "obvious thing", is

   -- easy to write, and hard to get wrong

   -- gives much less confusing error messages if you get it slightly
wrong

   -- easy to read

   -- uses a smaller subset of the language, so is especially easier
for non-C++ experts

   -- more general, in that it doesn't blow up and use silly amounts
of space (and probably more time too, given cache churn) if N is not
tiny

   -- more general also in that the same code does both the
general-purpose (n known only at runtime) and the special-purpose
job

 &gt; The C example relies on a fairly smart compiler to 
 &gt; do interprocedual analysis.

Depends what you mean by fairly smart.  This is standard stuff: gcc is
really not the best optimising compiler around.

 &gt; The C++ example only requires the inline keywork be honored, and
 &gt; you don't need explicit pow3 pow2, you have pow&lt;3&gt; pow&lt;2&gt; pow&lt;any
 &gt; constant&gt;.
 &gt; 
 &gt; Gives a bit more control over code generation.

It does.  I personally feel (actually have learned the hard way) that
using C++ templates for multi-stage programming is mostly much more
trouble than it is worth---especially when you realise what careful
exploitation of C-level specalisation by inlining can do.

If you really want more control over code generation (not forgetting
that just writing out what you want by hand is often the simplest
option in practice!) then I think C++ templates are a dead end---far
better to make the object language the same as the target language,
as in MetaOcaml and similar.

-------------------
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>

