Block Initialization

Tom Stockfisch tps at sdchem.UUCP
Thu Oct 30 15:27:17 AEST 1986


[ ">>" and "" is me (Tom Stockfisch), and ">" is Chris Torek ]

>>The obvious solution is to make assignment of zero to any structure a
>>defined operation guaranteed to get the appropriate bit patterns into
>>all the pointer elements. ...
>>
>>		struct big_sucker	var;
>>
>>		var =	0;	/* (no comment needed) */

>I dislike this: it is Yet Another Special Case.

I see this as *eliminating* a special case, since we already have

	double		x =	0;
	int		i =	0;
	long		j =	0;
	char		*p =	0;
	char		c =	0;
	struct foo	*bar =	0;

and (as a special case)
	
	struct foo	elt =	0;

is disallowed.  All this extension does (I think) is add one more conversion
rule, specifying how "0" gets widened to a "struct foo".
So what would be the harm?

>...I think the proper
>obvious solution is to allow aggregate structure constants:
>
>		var = { 0 };

Of course I would like this feature to be added as well, especially when I
have to deal with complex numbers.  If I had to choose, I would take
	
	var =	{ 0 };

since it is more powerful.

-- Tom Stockfisch, UCSD Chemistry



More information about the Comp.lang.c mailing list