Xref: utzoo comp.lang.c:30097 rec.arts.books:12445 Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!mailrus!ncar!boulder!pikes!aspen.craycos.com!pmk From: pmk@craycos.com (Peter Klausler) Newsgroups: comp.lang.c,rec.arts.books Subject: C operator precedence mnemonics Message-ID: <1990Jul4.164402.2072@craycos.com> Date: 4 Jul 90 16:44:02 GMT Organization: Cray Computer Corporation Lines: 38 In article <1990Jul1.065531.18620@acc.stolaf.edu> hannum@haydn.psu.edu (Charles Hannum) writes: > In a lot of cases, C operator precedence sucks. (I can quote K&R saying the > same thing -- different wording, of course. Lets not argue about this point.) > How does one deal with it? > My solution: Most of the time I know. When I don't, I try it one way, and if > it doesn't work right, I put parentheses in to force the issue. Many times I > just add them to begin with. C precedence: postfix, prefix, multiplication, add, shift, inequality, equality, bitwise AND, XOR, OR, logical AND, OR, ternary, assignment, comma It's easy to derive mnemonics to help you remember this. Here's some possibilities: Please put mice and such in each bag, Alice; except, omit lemmings and opossums - they aren't cute. PSUVM posts messages, and some involve Evil BIFF. Asinine expression often locates available opportunities to access communications. Pillsbury Poppin-fresh muffins are so inedible. Every bite aches excrutiatingly. Oh, lip agony! oh, tongue agony! call 911! Parsing precedences makes a simple implementation elusive. Big, automatically-executed, ordinary LR algorithms often take all core. Peter's process mangled addresses so important, Eric's bug analyzer executed old libraries, and oh! the administrator's confusion! If you prefer "relation" to "inequality" for {<,<=,>=,>}, then you could use: "Presidents prefer moronic actions," said Reagan. "Even Bush allows execution of lame activities, only to aggravate Congress." -Peter Klausler, writing compilers at Cray Computer Corp. in Colorado Springs