On 12-Nov-11 08:44, Eric Sosman wrote:
> On 11/12/2011 9:21 AM, Stephen Sprunk wrote:
>> On 11-Nov-11 15:54, Keith Thompson wrote:
>>> C99 changed the syntax to permit a trailing comma in an enum
>>> declaration. It would have made sense to permit a trailling
>>> comma for *any* comma-separated list. (Probably not for the comma
>>> operator, though.)
>>
>> Why not? If ";" is a valid statement, then why shouldn't ",;" be valid?
>
> Do you think `*;' should be valid?
>
> (If so, how many operands have been omitted?
Amusing, but sort of misses the point since it hinges on _how_ "," is
defined rather than defending _why_ it is so defined.
Absent side effects, "x,y;" is equivalent to "y;". The expression ""
cannot have side effects, so ",y;" should also be equivalent to "y;" and
therefore be valid.
Absent side effects, ",y;" is equivalent to ";". The expression ""
cannot have side effects, so ",;" should also be equivalent to ";" and
therefore valid.
Absent side effects, "x,;" is equivalent to "x;". The expression ""
cannot have side effects, so "x,;" should also be equivalent to ";" and
therefore valid.
The problem is that both operands must be evaluated by the operator
before it can discard the results, and the current language definition
does not define how to evaluate a null expression. However, what if it did?
This is similar to not allowing objects of type void; such an object is
obviously meaningless, but there are certain corner cases where
uniformity matters more than meaning.
S
--
Stephen Sprunk "God does not play dice." --Albert Einstein
CCIE #3723 "God is an inveterate gambler, and He throws the
K5SSS dice at every possible opportunity." --Stephen Hawking