Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!princeton!caip!seismo!rlgvax!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: net.lang.c,net.bugs Subject: Re: e1?(void_e2):(void_e3) so, is it legal or what? Message-ID: <518@hadron.UUCP> Date: Sun, 10-Aug-86 01:01:21 EDT Article-I.D.: hadron.518 Posted: Sun Aug 10 01:01:21 1986 Date-Received: Mon, 11-Aug-86 04:42:26 EDT References: <273@watmath.UUCP> <5858@alice.uUCp> <134@sas.UUCP> <155@cbnap.UUCP> <499@dg_rtp.UUCP> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Organization: Hadron, Inc., Fairfax, VA Lines: 52 Xref: watmath net.lang.c:10201 net.bugs:867 Summary: 'Tis not, Throop. In article <499@dg_rtp.UUCP> throopw@dg_rtp.UUCP (Wayne Throop) writes: >Any clod can have facts, but having opinions is an art. >> whp@cbnap.UUCP (W. H. Pollock x4575 3S235) >>> jcz@sas.UUCP (Carl Zeigler) >>>Scan again, Andrew, the (void) values are being thrown away. >> The void values are not thrown away! Remember that (A?B:C) is an >> expression *returning a value*. [paraphrase -j-] >K&R don't say anything, since no (void) back then. >Harbison and Steele say: > 3. They [the second and third subexpressions] may have identical > types (structure, union, enumeration, or void). The result is of > this same type. >ANSI C draft standard, C.3.15. > The first operand shall have scalar type. Both the second and third > operands shall have arithmetic type, or shall have the same > structure, union, or pointer type, or shall be void expressions. In > addition, one may be an object pointer and the other a pointer to > void, or one may be a pointer and the other a null pointer constant. > ... > If both the operands are void expressions, the result is a void > expression. >All fairly clear and straightforward. It is legal. *sigh* OK, let's get this straight. PROPOSED ANSI standard X3J11 describes a language (set of languages, over the past few years) that has (and have) not yet been implemented any- where by anyone (or if they have, word hasn't gotten to this corner yet). H&S, while a very good book, does take some liberties at interpretation. They are on the ANSI X3J11 committee, and could have been influenced in their interpre- tations by the committees deliberations. Most compilers today follow K&R, which by declaring that the conditional expression has (1) a result (2) with a data type predicated on the types of the operands, seems to be prohibiting use of void-type objects. Until recently, Proposed X3J11 concurred with this, specifically allowing only arith types, structures, unions, and pointers of the same type (remembering that "0" can be construed as a pointer of any type). Bottom line: it's a mite early to be pointing to Proposed X3J11 and saying something is "right" or "not right" based on that. Agreed, we should all follow and be aware (as I was not, of this) of things affecting our good programming practice. As of now, the standards are K&R with s3 and s5 enhancements. Anything that is not explicitly defined in one of these is subject to interpretation. As H&S points out, the C language is what the C compiler accepts. -- Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP} jsdy@hadron.COM (not yet domainised)