Standard for union initialization?

jim at ISM780B.UUCP jim at ISM780B.UUCP
Sat Feb 2 16:38:52 AEST 1985


>"Intelligent idea"??? This is just another accident waiting to happen!
>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.

I don't disagree with your observation, but please note that the
same argument can be applied to structure initialization.  The reason that it
is a nice idea is that it is isomorphic to structure initialization, so it
fits the existing structure; it doesn't involve any new mechanism, so it fits
within the committee's conservative charter.

Arguing that C's method of structure initialization is dangerous is a totally
different discussion; come up with better ideas for structure initialization,
and you will have come up with better ideas for union initialization.

-- Jim Balter, INTERACTIVE Systems (ima!jim)



More information about the Comp.lang.c mailing list