Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!nike!ucbcad!ucbvax!decvax!mcnc!rti-sel!dg_rtp!throopw From: throopw@dg_rtp.UUCP (Wayne Throop) Newsgroups: net.lang.c,net.bugs Subject: Re: e1?(void_e2):(void_e3) Message-ID: <511@dg_rtp.UUCP> Date: Mon, 11-Aug-86 13:39:01 EDT Article-I.D.: dg_rtp.511 Posted: Mon Aug 11 13:39:01 1986 Date-Received: Tue, 12-Aug-86 23:24:52 EDT References: <273@watmath.UUCP> <5858@alice.uUCp> <134@sas.UUCP> <155@cbnap.UUCP> <499@dg_rtp.UUCP> <1701@mmintl.UUCP> Lines: 39 Xref: mnetor net.lang.c:5616 net.bugs:316 > franka@mmintl.UUCP (Frank Adams) > It seems clear that according to the ANSI draft, e1?e2:e3 is legal when e2 > and e3 are both void. The next question is, should it be? > It seems to me that there are two different paradigms for how to interpret > the ?: operator here. One is as an ordinary operator, which returns one of > the values of e2 or e3, depending on the value of e1. Under this > interpretation, it does not seem to me appropriate to permit e2 and e3 void, > since in that case they have no values. Well, not quite. The standard takes the position that, while a void expression has no value, it has something that is close enough for government work. A way to think of is that a void expression indicates a "value" which requires no storage and has no legal operations (other than selection operations). Then specifically, the ?: operation chooses which of these odd non-value values to "evaluate". > The other paradigm is that e1?e2:e3 is precisely one of e2 or e3, depending > on the value of e1. Yes. The standard doesn't go this way. But I think it is reasonable for the standard to go the way it does, making void expressions legal wherever any other expressions are, except that their result is illegal as input for any but selection operations, such as (?:) and (,). Any other operation implies an interpretation and transformation of a value, and (void) cannot be interpreted or transformed, but these operations only imply evaluation and selection. So I agree that there are two reasonable interpretations of (?:), and the standard has chosen the first. But it has also chosen an interpretation of "what it means to be (void)" which makes void expressions to the right of a "?" reasonable. -- If a listener nods his head when you're explaining your program, wake him up. --- Alan J. Perlis -- Wayne Throop !mcnc!rti-sel!dg_rtp!throopw