[net.lang.c] A comment on aggregate constants

kpmartin@watmath.UUCP (Kevin Martin) (10/31/84)

>From mark (mwm@ea.UUCP)
>	struct gort {
>		int	type ;
>		union	info {
>				struct	gfloat	{ float	gfx, gfy } ;
>				struct	gint	{ long	gix, giy } ;
>				string	*name ;
>				} ;
>		} sample[] = {
>			{T_FLOAT, (struct glfoat) { 3.4, 5.7 } } ,
>			{T_INT, (struct gint) { 243, 56 } } ,
>			{T_STRING, (char *) "this is a test" }
>			} ;
>Comments?

Although I think that aggregate constants are a nice thing in themselves,
I still don't like the name-the-type approach to initualizing unions. I
prefer:
	struct gort {
		int	type ;
		union	info {
				struct	gfloat	{ float	gfx, gfy } gfl;
				struct	gint	{ long	gix, giy } gin;
				string	*name ;
				} ;
		} sample[] = {
			{T_FLOAT, gfl = { 3.4, 5.7 } } ,
			{T_INT, gin = { 243, 56 } } ,
			{T_STRING, name = "this is a test" }
			} ;
I believe that most C compilers now require you to give names to s/u elements
even if they are themselves s/u elements, so the first two union elements
are improperly declared in the first example.
               Kevin Martin, UofW Software Development Group