Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!ima!ISM780B!jim From: jim@ISM780B.UUCP Newsgroups: net.lang.c Subject: Re: Re: Standard for union initializatio Message-ID: <137@ISM780B.UUCP> Date: Wed, 23-Jan-85 00:52:59 EST Article-I.D.: ISM780B.137 Posted: Wed Jan 23 00:52:59 1985 Date-Received: Thu, 24-Jan-85 19:19:30 EST Lines: 27 Nf-ID: #R:tjalk:-41800:ISM780B:25500099:000:1060 Nf-From: ISM780B!jim Jan 22 11:05:00 1985 >I saw a suggestion in net.lang.c a few months ago that I found very sensible, >readable and hygienic: > > union { > int i; > float x; > char *str; > } ixstr = { , 3.14, }; > >if you want it to start off as a float, etc. > >Note that: >1. it is (almost) isomorphous to a struct initialization, >2. it also works nicely for arrays of unions. Very very nice! And if structure initialization is extended to allow (internal, due to the trailing comma hack) empty initializers to yield the default value (0), it is totally isomorphic. I presume that `ixstr = {, 3.14}' is ok. So the "first member rule" becomes the "+1'th member rule". Note that this is even compatible with the first member rule that Whitesmith's already implements, so Plauger will have no reason to quash it. Now if the committee continues to stick with the first member rule despite intelligent ideas like this, we should petition ANSI for a new committee. -- Jim Balter, INTERACTIVE Systems (ima!jim)