Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!elroy.jpl.nasa.gov!usc!wuarchive!emory!gatech!mcnc!rti!sheol!throopw From: throopw@sheol.UUCP (Wayne Throop) Newsgroups: comp.lang.c Subject: Re: cond. op. on ='s LHS Summary: think like you code, code like you think Message-ID: <1209@sheol.UUCP> Date: 18 Feb 91 02:51:48 GMT References: <326@smds.UUCP> <1196@sheol.UUCP> <331@smds.UUCP> <5672:Feb1814:26:0291@kramden.acf.nyu.edu> Lines: 34 > brnstnd@kramden.acf.nyu.edu (Dan Bernstein) > I'd write [..multi-line if statements instead of > cryptic one-liners involving ?: ..] So would I, 99 and 44 one-hundreths percent of the time. And the remaining .56 percent of the time wouldn't be for reasons of "efficency" or to "get close to the machine" or any such secondary goal. As Dan points out, such things are unlikely to win over the good ol' if-then-else. And yet... every now and then, one naturally thinks of a situation as assigning (or incrementing, or tweaking, or whatever) "the appropriate one of" a set of lvalues. Now, most often this is modeled as assignment to an array. But every once in a blue moon, the lvalues are not related by membership in an array, nor by anything much in particular beyond their participation in being one of the set of "appropriate ones" to assign something to. In such a rare case, I'd 'druther code the way I think about it, and think about it the way I code it.... that is, I'd really rather model it as a single assignment to a peculiar lvalue. So while I tend to agree that ?: in lhs expressions are, as a statistical tendency, an abomination, I can't agree that this is because of anything wrong with the idea in itself... just that the application's rightful place is very rare. The moral is (again): code like you think, think like you code. ( I hope this moral is thought provoking but essentially uncontroversial, but one never knows... ) -- Wayne Throop !mcnc!rti!sheol!throopw or sheol!throopw@rti.rti.org