caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: William Chesters <williamc@paneris.org>
To: caml-list@inria.fr
Subject: Re: [Caml-list] partial eval question
Date: Tue, 28 Oct 2003 10:46:24 +0000	[thread overview]
Message-ID: <16286.18688.149948.39036@beertje.william.bogus> (raw)
In-Reply-To: <200310272017.50686.yann.regisgianas@free.fr>

Yann Regis-Gianas writes:
 > I agree with you that constant folding, inlining and unrolling are well known 
 > by common compilers. However, when you want to _control_  these 
 > optimisations, this is more difficult with standard optimizers since they are 
 > black-boxes.

That's a strength as well as a weakness.  In reasonably simple cases
it "just works" and is less effort, more readable, more maintainable.

 > By adding the multi-stage evaluation into a programming language, we obtain 
 > one general,  transparent and simple tool. Why should we develop or learn the 
 > usage of many special-purpose optimizers ?

Partial/abstract evaluation is a pretty general purpose optimiser.
Half seriously: Metaml improves on C++ templates by making the
metalanguage the same as and more tightly integrated with the object
language.  Partial evaluation can almost be seen as going a step
further and having the compiler infer the tightest meta/object
boundary.  Perhaps if there was a way of telling the partial evaluator
"specialise this code block by value of parameter i / type of
parameter j / whatever" (*) it would handle all the everyday tasks for
which metaml is designed, and require considerably less effort and
expertise.

(*) to get this effect with good current compilers you have to isolate
the block in a function, turn up the inlining sufficiently, and use
"if" branches to trigger specialisation

 > By adding the multi-stage evaluation into a programming language,
 > we obtain one general, transparent and simple tool.

It's not simple or transparent, and for many tasks it isn't necessary.
Perhaps it's a good general tool for the generation of code for
numerics etc.---it may help specialist library writers.

For everyday programming I think one has to remember that heavyweight
attempts to achieve generality are often not worth it.  Simple
things can be done by the compiler or just written out by hand.
Complex things look nasty when hand-optimised, but if you try to do
them "better and more generally" using metaprogramming, you are likely
to take much longer, and end up with something which is hard to
decipher and disappointingly doesn't generalise in quite the way you
want.

There is little point in trading the "complexity" of prolix,
irritating but basically straightforward hand-specialised code for the
genuinely challenging complexity of a meta-programming system.  (It
really does become extremely complicated when you start taking into
account the detailed requirements of real world problems.)

The most viable option is often to settle on a reasonably general and
extensible conceptual framework (at the level of conventions rather
than anything more formal) and implement just the bits of it that you
actually need for your particular problem, encapsulated in a
consistent way.

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


  reply	other threads:[~2003-10-28 10:43 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 [this message]
2004-02-04  2:22         ` Walid Taha
2004-02-04  2:56     ` Walid Taha
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=16286.18688.149948.39036@beertje.william.bogus \
    --to=williamc@paneris.org \
    --cc=caml-list@inria.fr \
    /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).