Must a NULL pointer be a 0 bit patte
mwm at ea.UUCP
mwm at ea.UUCP
Sun Oct 28 16:15:00 AEST 1984
/***** ea:net.lang.c / utzoo!henry / 11:22 am Oct 23, 1984 */
As I understand it, nobody is claiming that the "first element" rule is
good; all they are claiming is that it's simple and does not have adverse
consequences elsewhere. Apparently the various alternatives all have
serious problems of one kind or another.
--
Henry Spencer @ U of Toronto Zoology
{allegra,ihnp4,linus,decvax}!utzoo!henry
/* ---------- */
Was one of the alternatives something similar to the ALGOLW "record constant"
facility? In C, this would translate to:
(struct gezornin) {"a", 10, 2.3, 'x'}
being considered a constant. Thus, you can do union initialization as so:
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" }
} ;
In other words, add a facility to allow structure constants (useful in *lots*
of places), and then require all union initializations to have an explicit
cast.
The union initializations won't break any existing code (nobody has them
now, right? :-), and the "struct constants" shouldn't break any code.
Comments?
<mike
More information about the Comp.lang.c
mailing list