Boost logo

Boost Users :

From: loufoque (mathias.gaunard_at_[hidden])
Date: 2006-10-12 13:03:33


William Xue wrote:

> Thank you very much! Your explanation is very clear. I am agree with you,
> it's nasty.

He said variable arguments were nasty. This is not the case of this
type-safe chaining.
 From what you're saying, it seems you understood it the other way
around. Excuse me if I am the one who understood you wrong.

> Though C/C++ is very flexible, I do not like to broke the regular rules of
> them.

C and C++ are different languages.
Variable arguments, a feature from C, has a lot of problems and
shouldn't be used at all in C++ since you can build better alternatives.

Using that kind of chaining is not "breaking the regular rules". It's an
usage of the generic paradigm from C++, which is what makes boost what
it is.

> Micrisoft have done something like this in their sample codes:
> ---8<--------------------------------------------->8---
> #define PURE =0
> ...
> interface xxx
> {
> ...
> int foo(...) PURE;
> ...
> };
> ---8<--------------------------------------------->8---
>
> I can not to find out any wisdom in doing things like this.

Usually you don't use the define PURE or a fake interface keyword, but
it is a very usual concept : it's an abstract base class.
It's only used in polymorphic designs though, which are unrelated to
boost.format.

> As a C/C++ user, I am very glad to see someone to extend the features of
> them,
> But IMHO, C/C++ is C/C++, do not go far away from the regular way.

C/C++ is nothing. It is a term usually used by people who code C++ using
C techniques.
There is C, and there is C++. Each one has its way of doing things. C
not having the features from C++, the C way is probably more dangerous
and less flexible.

The C way is to use variable arguments, which aren't type safe (which
probably leads to tons of problems) and only work for PODs.
The C++ way could be to use variadic templates, which aren't in the
standard yet, or to use operator overloading and do chaining (just like
the standard iostreams).

And also, if we didn't use a few tricks you may consider "not the
regular way", generic programming in C++ and therefore boost itself
would be very limited.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net