Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!vaxine!wjh12!genrad!decvax!harpo!eagle!mhuxl!ihnp4!inuxc!pur-ee!uiucdcs!uicsl!mather From: mather@uicsl.UUCP Newsgroups: net.lang.c Subject: Re: Precedence Question - (nf) Message-ID: <5548@uiucdcs.UUCP> Date: Sat, 11-Feb-84 22:46:08 EST Article-I.D.: uiucdcs.5548 Posted: Sat Feb 11 22:46:08 1984 Date-Received: Wed, 15-Feb-84 00:35:28 EST Lines: 27 #R:smu:13800001:uicsl:6400012:000:876 uicsl!mather Feb 10 14:13:00 1984 >Is cat = foo ? fu = bar : mouse; legal? > > legal 'according to K & R ..."? Well obviously it is legal. The question is: is bar assigned to fu before the result of ?: is assigned to cat? Perhaps this question has deeper undertones than I can perceive, but my understanding of precedence and order of evaluation was ?: (as a unit) had a higher order of precedence than = so that 'cat' gets the value of 'bar' or 'mouse' depending on the value of 'foo', rather than assigning 'cat' to 'foo'. But that's not what's happening. 'foo' is evaluated, if true, e2 (fu = bar) is evaluated and assigned to 'cat'. 'mouse' is left alone. If foo is 0 (false), then 'mouse' is evaluated and assigned to 'cat'. 'fu' is never set to 'bar' in this case. (K&R top of p48). foo is e1 in e1 ? e2 : e3 fu = bar is e2 mouse is e3 B.C.Mather Le Maitre ...uiucdcs!uicsl!mather