Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!cs.utexas.edu!yale!hsdndev!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.lang.c Subject: Re: cond. op. on ='s LHS Message-ID: <5672:Feb1814:26:0291@kramden.acf.nyu.edu> Date: 18 Feb 91 14:26:02 GMT References: <326@smds.UUCP> <1196@sheol.UUCP> <331@smds.UUCP> Organization: IR Lines: 41 In article <331@smds.UUCP> rh@smds.UUCP (Richard Harter) writes: > Let's run down the line on this. First of all the trick of using > *(cond?&var1:&var2) is not technically legal since the result of the > ?: is not an lvalue. Say what? It doesn't matter whether foobiebletch is an lvalue as long as nobody tries to assign a value to it. Here foobiebletch is a (non-const) pointer type, so *foobiebletch is an lvalue, and *foobiebletch = x is fine. > Secondly the syntax of the condition is, in its own right, ugly. Yes. I'd write either { register glorp *addr; if (cond) addr = &var1; else addr = &var2; *addr = expr; } or { register glorp temp; temp = expr; if (cond) var1 = temp; else var2 = temp; } if any of the expressions involved were particularly complex. How else would the machine do the job anyway? > There really is a need for > conditional expressions. This can be argued. ?: is almost purely syntactic; I don't know any machine that will optimize a ?: expression better than an equivalent if-then. Its syntactic benefits are minimal at best. ---Dan