trailing comma inside enum...bug or feature?
Wonderly
gregg at ihlpb.ATT.COM
Fri Dec 9 01:52:42 AEST 1988
>From article <9095 at smoke.BRL.MIL>, by gwyn at smoke.BRL.MIL (Doug Gwyn ):
> In article <2174 at vedge.UUCP> lai at vedge.UUCP (David Lai) writes:
>>Is this a bug or feature?
>
> An unofficial feature.
>
>>Should ANSI compilers allow this?
>
> Definitely not! Trailing comma in an initializer list is allowed, though.
At first sight it appears to not be necessary, however it does prove to
be a benefit in some software modification control environments that I
know about. If the initial definition of an enum is say
typedef enum FOO {
VALUE1,
VALUE2,
} FOO_CONST;
and a modification changed it to
typedef enum FOO {
VALUE1,
VALUE2,
VALUE3
} FOO_CONST;
and finally another modification changed it to
typedef enum FOO {
VALUE1,
VALUE2,
VALUE3,
VALUE4,
} FOO_CONST;
The modification control system that I know about would say that the
third modification is 'dependent' on the second in a physical way
because a line of code was changed. Now obviously, the comma could
be placed on the line with VALUE4, but that is not the typical nor
desireable coding style.
By leaving the trailing comma there, future modifications are easily
made without additional changes and dependencies needed.
--
It isn't the DREAM that NASA's missing... DOMAIN: gregg at ihlpb.att.com
It's a direction! UUCP: att!ihlpb!gregg
More information about the Comp.std.c
mailing list