Boost logo

Boost :

From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2003-06-26 16:13:31


> > Not to the Boost library version. At least, not until
> variadics and
> > placemarkers are part of C++.
>
> But variadics are a part of C. Though this is a bit outside
> of Boost's mission, the PP lib is arguably even more useful
> to C programmers than it is to C++ programmers. I don't see
> any harm in targeting C programmers for this particular
> library, since they could be an important user base; as long
> as it doesn't compromise the library's usefulness for C++ programmers.

It isn't that it isn't worthwhile to support them. Rather, it is
because there are already about three (on average) different
implementations of the pp-lib to work around various (sometimes serious)
compiler deficiencies. Supporting variadics and placemarkers from C99
would add, at minimum, two more versions of about half the library.
That's why I don't want to support a "variadic" mode in general in the
pp-lib at this point. However, that isn't why I don't want to add
support for variadic parameters as a data type. (I'll address that
below in more detail.)

> > OTOH, the Chaos version of the library, which is nearly
> complete, has
> > full support for variadics and placemarkers from the ground up.
>
> I'm looking forward to your release of Chaos. Maybe this
> exercise is just a learning experience for me, if you already
> have implemented better variadic support in Chaos.

Chaos is implemented from the ground up to support variadics. However,
it doesn't directly support variadics as a data structure. The reasons
for this are simple: 1) Variadic data can contain open commas and that
interferes with parameter lists if you need to pass around more than one
structure or if you need to use the variadic argument for something
else. 2) There is no way (without resorting to undefined behavior) of
detecting whether you're at the end of the variadic parameters. There
are only two reasonable ways to do it: First, make an "end" rogue value
that is pathological but detectable as opposed to any other possible
input. 3) There is no such thing as a "nil" variadic parameter. There
is *always* at least one parameter, though that parameter might be empty
(a.k.a. "placemarker"), and second, limit the number of variadic
parameters. Altogether, these issues make dealing with variadics as a
data structure not worthwhile when you can just wrap the elements in
parentheses and call it a "tuple." (BTW, even tuples are only supported
up to a fixed size in Chaos because of the "end-of-data" issues
mentioned above.)

Support for variadics in Chaos, as far as algorithms are concerned, is
to allow the data/state to be variadic. This is far more useful in
practice, as it gets rid of a massive about of "element access" from one
structure or another.

Regards,
Paul Mensonides


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