Boost logo

Boost :

Subject: Re: [boost] [preprocessor] Warning: Incoming
From: Edward Diener (eldiener_at_[hidden])
Date: 2011-07-01 20:13:19

On 7/1/2011 6:44 PM, Paul Mensonides wrote:
> On Fri, 01 Jul 2011 08:34:35 -0700, Eric Niebler wrote:
>> On 6/30/2011 11:09 PM, Paul Mensonides wrote:
>>> ...but this is terrible. It doesn't take away from the point of the
>>> talk, but it should be something like count<typelist<A, B, C>>, not
>>> count<A, B, C>.
>> I'm not disagreeing, but I'd like to know why you believe this is true
>> for templates as well as macros.
> I'd go further and say that it would be terrible to use variadic argument
> lists (the function parameter kind, not the template parameter kind) to
> as runtime data structures also. Off the top of my head, here are some
> reasons:
> 1) It forces a particular argument order. By itself, this isn't the end
> of the world, but either tends to break symmetries or tends to require
> argument orders to change on a bunch of other things.
> 2) It does not play well with overloading (via number of arguments with
> macros--which you can do, via specialization of templates, or via plain
> overloading of functions).
> 3) It frequently destroys the ability to use default arguments (which
> could be accounted for if it weren't for #2).
> 4) It does not work when multiple data structures need to be passed (e.g.
> Cartesian products).
> 5) It removes the ability to use the *single* variadic clump for other
> stuff.
> I don't have a problem with variadic data used to initialize regular data
> structures in the right contexts. For example, make_tuple(a, b, c). (I
> do believe, however, that std::initializer_list<T> is a misfeature. I
> personally think the { a, b, c } should have been mapped onto a
> constructor call taking a, b, and c--which may or may not use variadic
> templates).

I agree that using variadic argument lists as opposed to a data
structure containing the data ( list, vector, etc. ) is a poor way to
design in general. But sometimes one creates interfaces with which
programmers are more comfortable just for the sake of end-user ease.
This goes back discussions about variadic data in macros being a more
natural way of passing data to macros than pp-lib data structures. When
i created VMD, and subsequently worked with you to add variadic data to
pp-lib, I was always quick to acknowledge that my main reason for doing
so was almost entirely to satisfy end-user expectations of the way macro
parameters are normally passed. Other than that variadic data in macros
holds no advantage to pp-lib data structures and can generally be ignored.

In the same way a designer may decide to create fairly simple
functionality using variadic argument lists, just to satsfy end-user
programmer expectations. While in the vast majority of cases it should
be avoided for all the reasons you give above, and mostly because it is
just a poor way of designing software of any complexity.

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