Boost logo

Boost :

From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2003-01-06 17:20:34


>From: "Alisdair Meredith" <alisdair.meredith_at_[hidden]>

> Terje Slettebø wrote:
>
> > The results don't necessarily have to be printed out at
> > compile-time (Erwin Unruh printed the results using compiler-warnings,
but
> > that is of course highly implementation dependent).
>
> > "Hello, world" in compile-time programming doesn't necessarily have to
be
> > the same kind of program as in run-time programming, since the way it
works
> > is different.
>
> I suspect a metaprogram that does nothing but issue a few diagnostics
> would be dismissed as a curiosity, maybe a cool toy, but hardy seen as
> an interesting tool by someone new to the idea.

Unlike the traditional "Hello, world"? A "Hello, world" programs isn't meant
to show the advantage of C++, but to be a complete and minimal program that
does something interesting, so that you may get a gentle introduction to the
language, and you can see how programs in the language look, and also check
that the system (compiler, etc.) is set up properly. The absolute minimal
program is of course "main() {}", but as it doesn't do anything, it isn't
very interesting.

There was a discussion a long time ago in "Communications of the ACM", about
"improving" "Hello, world", which meant making it more complex. As Kevlin
Henney said about it, it missed the point completely, as it's supposed to be
a complete, minimal program, that does something interesting.

To this end, I think simple programs, like the ones mentioned, may fit. It
may also include doing something useful, such as your suggestion, here.

> Creating a static array of size 5! shows a little more potential, but
> what to do with the array?

Filling it with all permutations of the numbers 1-5?

> However, it is far too easy to be negative when I have nothing better to
> offer in return (although I will be quite keen to see the final example,
> MPL is one of those items on my 'to-do' list that never quite hits the
> top)
>
> What are people actively doing with MPL anyway?

I'm using mpl::if_<> to simulate partial specialisation in the lexical_cast
proposition. It used to use <boost/pending/ct_if.hpp>, but as MPL is now of
Boost, I've used that. (The version in the Files section still uses ct_if,
though, as it hasn't been updated.) So it's hardly groundbreaking things, :)
and it could be done earlier, too. However, simple components like if_<> is
often useful, for the same reason that "simple" components like Boost.Ref
and Boost.Bind is useful - they do one thing well.

> Perhaps and answer to
> that question will indicate what 'Hello world' should look like. It
> should be more than a neat exercise in syntax, it should demonstrate the
> idea of real-world use.

I think it's a good idea to get real-world examples of metaprogramming.
However, that may not be much like "Hello, world", as also Dave Abrahams
mention in another posting. You can of course have both simple and more
complex examples.

Regards,

Terje


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk