Path: utzoo!attcan!uunet!bfmny0!tneff From: tneff@bfmny0.UU.NET (Tom Neff) Newsgroups: comp.lang.c Subject: Re: why bother with operator precedence Message-ID: <15289@bfmny0.UU.NET> Date: 27 Mar 90 08:21:24 GMT References: <2205@osc.COM> <340018@hplvli.HP.COM> <19356@megaron.cs.arizona.edu> <1379@ux.acs.umn.edu> <2031@l.cc.purdue.edu> Reply-To: tneff@bfmny0.UU.NET (Tom Neff) Lines: 25 In article <2031@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: >It is much worse. The precedence rules in algebra are well known, but the >arbitrary ones in C are not, and are not intuitive. What is the precedence >for > > a << b + c I think the point was that you should say what you mean, i.e. (a << b) + c or a << (b + c) as appropriate, in code that you write. I try to do this myself in cases where there might be any doubt among those who don't have prefrontal YACC implants :-). However it's probably a good idea to run C students through the list, because they will someday have to READ code as well as write it. It would also be nice to write and pass around a tiny public domain utility that takes any C expression and parenthesizes it to the max. -- "How can a man of integrity get along /// Tom Neff in Washington?" -- Richard Feynman /// tneff@bfmny0.UU.NET