Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 alpha 4/15/85; site plus5.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!ihnp4!mgnetp!we53!busch!wuphys!plus5!hokey From: hokey@plus5.UUCP (Hokey) Newsgroups: net.lang.c Subject: Re: Initialization of unions Message-ID: <765@plus5.UUCP> Date: Wed, 5-Jun-85 23:48:04 EDT Article-I.D.: plus5.765 Posted: Wed Jun 5 23:48:04 1985 Date-Received: Sun, 9-Jun-85 03:24:30 EDT References: <477@tjalk.UUCP> Reply-To: hokey@plus5.UUCP (Hokey) Organization: Plus Five Computer Services, St. Louis, MO Lines: 27 In article <477@tjalk.UUCP> dick@tjalk.UUCP (Dick Grune) writes: >I saw a suggestion for the initialization of unions 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. I don't see this as sensible or readable (I'm not sure about hygienic, either). For starters, if one has a union of many elements, the initialization string is *huge*. For another, if elements are added, deleted, or reordered, the initialization string must be fixed. Thirdly, one has to look at the definition quite often when examining an array union initialization in order to keep everything in perspective. I still believe the best answer is to explicitly cast each initializer. It sure would be nice if the net could get some additional feedback from the Committee on this issue. -- Hokey ..ihnp4!plus5!hokey 314-725-9492