expr ? (void) : (void)

Rick Genter rgenter at BBN-LABS-B.ARPA
Thu Jul 31 05:06:33 AEST 1986


     Before we go overboard on this issue, let's take a look at a couple of
points:

	1) C has no "function call statement".  Instead it has an "expression"
	   statement which allows for constructs such as:

		printf ("Hello world\n");
		ptr ++;
		x + 57;			/* useless, but allowed */
		blatz ();

	2) Functions may be declared to be of type (void).  For example,

		void
		blatz ()
		{
			printf ("Hello world\n");
		}

Obviously, given 1) and 2), certain exceptions relating to the use of values
of type (void) have been implemented.  Yes, you can not have:

		void	x ();
		int	y;

		y = x ();

since you are really trying to "use" a (void) value.  However, I claim that
it should be as legal to say:

		z ? x () : y ();

as it is to say:

		if ( z )
			x ();
		else	y ();

when both x and y return (void), given that C *already knows how to throw away
the value of a (void)*.
--------
Rick Genter 				BBN Laboratories Inc.
(617) 497-3848				10 Moulton St.  6/512
rgenter at labs-b.bbn.COM  (Internet new)	Cambridge, MA   02238
rgenter at bbn-labs-b.ARPA (Internet old)	linus!rgenter%BBN-LABS-B.ARPA (UUCP)

Yow!  Now I get to think about all the BAD THINGS I did to a BOWLING BALL
 when I was in JUNIOR HIGH SCHOOL!



More information about the Comp.lang.c mailing list