Block Initialization

Chris Torek chris at umcp-cs.UUCP
Wed Oct 29 08:53:26 AEST 1986

In article <414 at sdchema.sdchem.UUCP> tps at sdchemf.UUCP (Tom Stockfisch) writes:
>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 think the proper
obvious solution is to allow aggregate structure constants:

		var = { 0 };

The compiler can (*internally*) recognise this as a special constant
and not generate a static data object.  Aggregate structure constants
have other nice features:

		struct foo x;

		f((struct foo) { 1, 27.3, "Hello world" });

They have problems as well; witness the ugly syntax used to attach
a type to an otherwise typeless aggregate.  As with the nil pointer
constant `0', aggregate constants can pick up their types from
expression context, but there are always cases where the context
is missing.
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at

More information about the Comp.lang.c mailing list