Standard for union initialization

guido at boring.UUCP guido at boring.UUCP
Fri Feb 1 00:37:45 AEST 1985


In article <11143 at watmath.UUCP> kpmartin at watmath.UUCP (Kevin Martin) writes:
>This looks ok for a nice short example like this, but frequently, the
>union's definition and initialization are far apart (and maybe in different
>source files). This makes it easy to add another union element, and
>inadvertantly screw up the initializers royally without as much as a
>peep from the compiler.

Why is this proposal attacked so vehemently?  All arguments I hear
against it (and it is really the same argument all the time) can be
used against structure initialization as well: the meaning of the
initialization depends on the order of the elements in the struct/union
declaration.

So?  Don't change the order of elements when there are initializations
around, or be prepared to hack your way through the program and spot
the initializations.  For unions, the problem of adding another element
is even less of a problem:  since the order of initializations is
unimportant *except for the proposed initialization feature* (this is
true even for the first member rule!), new elements should be added to
the end of the union.

	Guido van Rossum, "Stamp Out BASIC" Committee, CWI, Amsterdam
	guido at mcvax.UUCP

"Life is like a sewer.  What you get out of it, depends on what you put
into it."



More information about the Comp.lang.c mailing list