James Kanze
11/15/2008 10:00:00 AM
On Nov 15, 5:04 am, Old Wolf <oldw...@inspire.net.nz> wrote:
> On Nov 13, 11:04 pm, James Kanze <james.ka...@gmail.com> wrote:
> > On Nov 13, 1:28 am, Juha Nieminen <nos...@thanks.invalid> wrote:
> > > Old Wolf wrote:
> > > > On Nov 13, 12:46 pm, "webinfin...@gmail.com" <webinfin...@gmail.com>
> > > >> #define D(y...) (const int []) {y}
> > There are actually two things in the above which cause syntax
> > errors in current C++. The first is that it is a variadic
> > macro, which is legal in C99 and will be legal in the next
> > version of C++.
> Variadic macros in C99 look like:
> #define D(y, ...)
> i.e. the ellipsis is separated from the other
> arguments by a comma (with optional whitespace).
So I see. I wonder why they didn't support the form without the
comma, as they do in function declarations. Shocking lack of
orthogonality.
(Historically, the comma wasn't allowed in function
declarations; the syntax was exactly that of a natural language,
where you would never write "a, b, ..." but always "a, b...".
When C adopted this syntax from C++, the C committee decided to
allow the syntax with the comma as well; I'm not sure what their
reasoning was, but I also find it more appealing, separating the
.... from the preceding argument. But not enough more appealing
to have justified changing or extending the existing
specification; if it were a new invention, I'd define it with
the comma, but since it wasn't, and isn't, I don't think that
there was, or is, sufficient justification to add the form with
the comma.)
> The ellipsis directly following the argument name, isn't in
> any C standard. (Another poster suggests that it's a GCC
> extension).
Might be. I would certainly expect that most implementations
supporting vararg templates support it (except maybe in their
strictest modes), much like they support a final comma in an
enum list. There is absolutely no reason not to be orthogonal
here (and I would consider this a defect in the C standard).
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34