caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Walid Taha <taha@cs.rice.edu>
To: William Chesters <williamc@paneris.org>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] partial eval question
Date: Tue, 3 Feb 2004 20:56:58 -0600 (CST)	[thread overview]
Message-ID: <Pine.LNX.4.44.0402032051540.17089-100000@boromir.cs.rice.edu> (raw)
In-Reply-To: <16285.15401.421786.814601@beertje.william.bogus>


On Mon, 27 Oct 2003, William Chesters wrote:

|Damien writes:
| > Multi-Stage Programming is your friend...
| > <http://www.cs.rice.edu/~taha/MSP/>
| > 
| > let rec pow n = .< 
| > 	.~(match n with
| > 		| 1 -> .< fun x -> x >.
| > 		| n -> .< fun x -> x * .~(pow (n-1)) x>.
| > 	)
| > >.
| > 
| > (pow 3) get reduced into .<fun x -> 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


  parent reply	other threads:[~2004-02-04  2:57 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-27  1:41 Ben Kavanagh
2003-10-27  7:14 ` Damien
2003-10-27 15:39   ` William Chesters
2003-10-27 18:50     ` Andrew Lenharth
2003-10-27 19:12       ` William Chesters
2003-10-27 20:08         ` Jacques Carette
2004-02-04  3:03           ` Walid Taha
2003-10-27 22:11         ` Andrew Lenharth
2004-02-04  2:59       ` Walid Taha
2004-02-04  5:53         ` Andrew Lenharth
2004-02-05 21:29           ` Walid Taha
2003-10-27 19:17     ` Yann Regis-Gianas
2003-10-28 10:46       ` William Chesters
2004-02-04  2:22         ` Walid Taha
2004-02-04  2:56     ` Walid Taha [this message]
2003-10-28 15:09   ` Dmitry Lomov
2003-10-27 15:16 ` Vincent Balat [prof Moggi team]
2004-02-04  2:51 ` Walid Taha
2004-02-04 10:26   ` Ben Kavanagh
2004-02-04 10:32   ` Ben Kavanagh
2004-02-05 21:11     ` Walid Taha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44.0402032051540.17089-100000@boromir.cs.rice.edu \
    --to=taha@cs.rice.edu \
    --cc=caml-list@inria.fr \
    --cc=williamc@paneris.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).