Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!hsdndev!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: cond. op. on ='s LHS Message-ID: <15231@smoke.brl.mil> Date: 17 Feb 91 20:03:11 GMT References: <326@smds.UUCP> <15227@smoke.brl.mil> <1196@sheol.UUCP> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 22 In article <1196@sheol.UUCP> throopw@sheol.UUCP (Wayne Throop) writes: >-- [.. some context restored ..] >-- *(a==b?&c:&d) = >- There are good ways of exploiting the ?: operator and bad ways. >- The example being discussed is clearly among the latter. >I'm not sure I understand. Could either Doug or Richard expand a little >on just why the expression is "ugly" or a "bad way" to exploit the >conditional operator? You mis-restored the context. The original example did NOT assign the value of "some complicated messy expression"; rather, it assigned the integer constant 1. It is an abuse of the potential utility of the ?: operator to use it, especially with the addition of levels of indirection, where a simple if ( a == b ) c = 1; else d = 1; would be much clearer and (assuming a decent compiler) at least as efficient. I doubt that efficiency should have been an issue anyway; however, clarity is very important. If you doubt that, some remedial reading of software engineering classics is indicated.