Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!bbn!cc5.bbn.com!keesan From: keesan@cc5.bbn.com.UUCP Newsgroups: comp.lang.c Subject: Re: Returning a value from ?: Message-ID: <1464@cc5.bbn.com.BBN.COM> Date: Mon, 1-Jun-87 17:25:29 EDT Article-I.D.: cc5.1464 Posted: Mon Jun 1 17:25:29 1987 Date-Received: Fri, 5-Jun-87 01:42:03 EDT References: <7555@brl-adm.ARPA> Reply-To: keesan@cc5.bbn.com.UUCP (Morris M. Keesan) Organization: Bolt Beranek and Newman, Cambridge, MA Lines: 19 In article <7555@brl-adm.ARPA> DAVE%UWF.BITNET@wiscvm.wisc.EDU writes: > > (f(a) * f(p) > 0) ? (a = p) : (b = p); > >Is the above >statement not valid C code? Should the result be put into a variable of >some sort? I am aware of the philosophy that all expressions should >return a value, and that the value returned should be referenced. So >is Turbo just enforcing that, or should Borland have allowed it to pass >with a warning? Sounds like your problem was simply a bug in the compiler. The above expression is perfectly valid, and the expression (a = p) returns a value just as much as any conditional expression. You can't reference the value of every expression, nor is there any reason to. -- Morris M. Keesan keesan@cci.bbn.com {harvard,decvax,ihnp4,etc.}!bbnccv!keesan