Article View: comp.lang.misc
Article #6293Re: Union initialization
From: Ex-God
Date: Sat, 25 Feb 1989 07:50
Date: Sat, 25 Feb 1989 07:50
29 lines
1587 bytes
1587 bytes
In article <11860@haddock> karl@haddock.ima.isc.com (Karl Heuer) asks:
>Would the following be workable?
> int a[3] = { 0: 3, 2: 5 };
Yes, but as arrays are inherently ordered, there's no reason to ignore
the ordering -- the comma-separated format is much better for small arrays:
int a[3] = {0, , 2};
> union { float f; int i; char *c; } u[3] = {
> { f: 1.0 },
> { i: 76 },
> { c: "STUG" }
> };
In the case of unions and structures, on the other hand, this idea
makes sense, as they are ordered only because it is necessary.
The only question is whether it is more important to make all
initialization consistent, or to make all initializations look clear
and obvious. It would probably be best to allow any complex type to use
either the labelled format or the comma-separated format -- it might
be useful to intialize the first and 230th elements of an array with
the labelled format, but it would be easier to initialize the first
100 elements except the 3rd with the comma-separated format.
Andrew Barnert (Smilin' Jack // ex-God // etc.)
ins_balb@jhunix
Technical Details
Message-ID:
<867@jhunix.HCF.JHU.EDU>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!ames!mailrus!uflorida!haven!aplcen!jhunix!c08_d103References:
<51116@yale-celray.yale.UUCP> <437@lakart.UUCP> <11860@haddock.ima.isc.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!ames!mailrus!uflorida!haven!aplcen!jhunix!c08_d103 From: c08_d103@jhunix.HCF.JHU.EDU (Ex-God) Newsgroups: comp.lang.misc Subject: Re: Union initialization Keywords: D Message-ID: <867@jhunix.HCF.JHU.EDU> Date: 25 Feb 89 07:50:59 GMT References: <51116@yale-celray.yale.UUCP> <437@lakart.UUCP> <11860@haddock.ima.isc.com> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: The Johns Hopkins University - HCF Lines: 29