enum, no trailing comma?

Doug Gwyn gwyn at smoke.BRL.MIL
Mon Aug 20 10:02:52 AEST 1990


In article <8 at christmas.UUCP> rtm at christmas.UUCP (Richard Minner) writes:
>mean that a trailing comma:
>	enum foo { one, two, three, };
>is disallowed?

Yes, the syntax does not permit a trailing comma after the list.
This was the result of an explicit vote in X3J11.  The basic argumentation
was that optional trailing comma after initializer lists was required by
the existing practice and had been deliberately intended (presumably to
facilitate automatic generation of such lists, although I find that a weak
reason), so that little bit of sloppiness had to be supported by the
standrad; however, it was generally felt that there was no need to extend
the syntactic sloppiness to the case of enumerator lists also.

>I've been told that nothing really changed from Dec 7, 88 to the final
>version, but maybe this did, right?  (an aside: is it true that nothing
>changed besides unary + ?)

I'm not exactly sure which draft that was, but it is dated after the
responses to the third formal public review, and since there were no
substantive changes made as a result of the third public review or
subsequent actions, just editorial clarifications etc., I suspect that
indeed the "Dec 7, 88" dpANS was substantially equivalent to the final
ANS.

>Are compiler vendors likely to consider such a comma a real live syntax
>error?  I suppose they have to.

Yes, syntax violations require a diagnostic.

>(Maybe it was just too hard to specify the syntax to allow a
>trailing comma? :-)

No, in fact X3J11 had several experts in formal syntax specification,
and could easily have allowed an optional comma if we had voted to do so.



More information about the Comp.std.c mailing list