Boost logo

Boost :

From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2002-08-12 00:28:01


>From: "Paul Mensonides" <pmenso57_at_[hidden]>

Just to reply to part of the posting.

>> From: "Douglas Gregor" <gregod_at_[hidden]>
>
> A vector of types that is large is difficult to maintain because there are
so
> many elements. Maybe I don't understand what you mean by type-vectors.
What I
> mean by them is a series of types that is defined in a tuple-like fashion:
>
> <snip>
>
> I'm not making the case for typelists, I'm making the case that multiple
pure
> sequence types are not necessary. I totally agree that type-vectors of
some
> kind are inherently faster than cons-style lists. Do you have another
example
> that implemented with a typelist that is inherently better implemented
with a
> typelist?

I've already showed you, and you've pointed it out, yourself, that
implementing large vectors tend to be difficult, as they are fixed size, in
the source. This means you either have to use the preprocessor (if
possible), or manually create large sources with the maximum fixed size you
want. This could bloat MPL enourmously. How large should the maximum be?
100? 500? 1000? 10,000? No matter what number you choose, someone might want
a bigger one. Using large vector sources like this, if the size isn't
needed, may slow the compilation down considerably.

Lists, on the other hand, have no fixed size in the source, and need no help
from the preprocessor.

To address your efficiency argument: If you manually duplicate (or feed the
output of the preprocessor to a file), then you may end up with a large
library, and if you use a large vector where one isn't needed, it may become
inefficient, because of all those unused elements that are carried around,
and compiled. You may alleviate the latter some, by having different size
vectors included at compilation time, depending on what is used (which is
already done in MPL, selecting between 10-50 elements, in 10 element steps).
However, the scale of this means that you may get very large sources, and no
matter how large you make them, they may not be enough.

If, on the other hand, you use the preprocessor, to generate it on the fly,
that brings its own overhead, and limitations on size.

Bottom line, you can't have your cake and eat it too. In MPL, vectors and
lists have different performance characteristics, one way or the other.

Regards,

Terje


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