Boost logo

Boost :

From: Jeremy Maitin-Shepard (jbms_at_[hidden])
Date: 2003-10-26 01:18:21

"Joel de Guzman" <joel_at_[hidden]> writes:
>> "Jeremy Maitin-Shepard" <jbms_at_[hidden]> wrote in message
>> news:87ad7o7pxd.fsf_at_jay.local.invalid...
>>> [...]
>>> (This post is rather off topic, but I thought I would post it
>>> anyway)
>>> [...]
>>> Imagine if C++ supported syntax like this:
>>> typedef typename {
>>> type x = mpl::vector<int, bool, short, double>;
>>> type y = mpl::vector<float, unsigned int>;
>>> for(type it = begin<y>; it != end<y>; it = next<it>)
>>> x = push_back<x, deref<it> >;
>>> return x;
>>> } my_vector;
>>> [...]
> It would be very difficult to debug because of the side-effects.
> I'm quite happy with the *functional* nature of the template processor,
> thank you. An imperative template processor will open up a can of
> worms. I don't even want to start imagining a step debugger at
> compile time! Yaiks! No, please don't!

I think to the contrary it would be easier, or at least no more
difficult to debug as it is now. The compiler simply needs to output
the type of each of the local `type' variables. As I see it, that is
much easier to deal with that than a chain of 15 template instantiation

> IMVHO, there's nothing wrong with the functional nature of the template
> processor. Why make it imperative when everyone knows that
> functional is better? C'mon guys! This is a step backwards!

I think the example I gave clearly indicates the advantages of
imperative template meta-programming. The "functional programming"
that is done with templates is actually just a subset of the
functionality that would be possible with an imperative template
processor. If meta-functions were supported as suggested, and there is
a real advantage to using functional programming, it could still be
used, with more elegant syntax in fact.

Jeremy Maitin-Shepard

Boost list run by bdawes at, gregod at, cpdaniel at, john at