Boost logo

Boost :

From: Andrei Alexandrescu (andrewalex_at_[hidden])
Date: 2002-04-10 12:21:21


"Emily Winch" <Emily.Winch_at_[hidden]> wrote in message
news:77D94A9BDCEFD3119DF100D0B73EA6A8014A6D05_at_teleca126...
> It seems to me that the aim of the MPL is to provide a foundation
for
> libraries such as Loki, so that those libraries can concentrate on
> domain-specific tasks rather than metaprogramming trivia. Handling
typelists
> is a major part of its job. If people are finding that the core
facilities
> of the MPL are _not_ suitable for their intended purpose, I think it
would
> be worth some considerable effort to establish exactly what are the
> difficulties with the MPL, and to address those issues _within the
MPL_, as
> well as or instead of recreating a subset of its features.

Ok, I'll try to detail my view. (Warning, many "I"s and "me"s ahead,
again. This is to protect myself for making wrong generalizations.) My
problem with mpl is that I see it as an abstraction going in the wrong
direction.

The C++ template engine is a Turing complete, pure functional
language. In pure functional languages recursion is natural, iteration
is ab(d)ominable. This is a fact, and I believe anyone would agree
with that.

I personally programmed non-functional languages most of the time, but
I prefer "nice code" to "non-functional code at all costs".

MPL strives to add non-functional abilities to the template engine. It
features loops, iterations, iterators, and the such. The intellectual
effort invested in it is impressive. After all, MPL works in a
language that's completely unfrendly to what MPL wants.

As much as I am impressed with MPL's intellectual investment, I am
completely underwhelmed by its approach by large, and in principle. (I
am sorry, there's nothing personal to MPL's authors. That's how I
feel.) I would look the same at a package that adds iterations, loops,
etc. in Haskell. I am much more comfortable with iteration than with
recursion, but again, in Rome do what the Romans do: Haskell does not
like loops, and neither does C++'s template engine.

So I ask: why? To what end?

Note that we're not talking about a problem that has no other
solution. Au contraire, it's about a problem which has a much more
elegant solution.

Why?

What I think would be reasonable to ask, for example, is a basic "list
of types" facility, with typical primitives for lists of types:
append, erase, find, etc. Yet I cannot look at MPL's incarnation of
these simplest facilities, without shrieking in horror. And I imagine
that the error messages generated by mpl's misuse are really bad, but
that's a moot point - all template error messages look bad :o).

By comparison, Loki's typelists are - to me at least - an example of
elegance and simplicity. They are just so cool and elegant. And in all
honesty, I hope I'm not being blurred by the fact that they're
implemented by myself. I'm proud to show loki's typelists to any
fellow programmer; I'd be ashamed to show mpl's typelists to even
expert C++ programmers.

> Is it really possible to create one metaprogramming library that
addresses
> the needs of the majority of the people the majority of the time? If
not,
> why not? and if so, let's make sure we have it! Even if this turns
out to be
> quite a long term aim.

I don't know. What I /feel/ is that MPL simply goes in the wrong
direction. I don't want iteration and loops in the template engine. It
is a pure functional language, and in functional languages you recurse
(recurse = curse again :o)).

> This is really a plea for some solid constructive criticism of the
MPL
> coming out of all this.

I guess all of the above is not very constructive, and I am truly
sorry about that. The least thing I want to do is to cause more
discussion in contradictory.

If I believe mpl should be added to boost? One opinion doesn't matter
much, but if you asked me, I'd say, if many people love it (and I
believe they don't), of course. If I enjoy it being shoved down my
throat? Hell no.

Andrei


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