> >I used to look for programmers who wrote "if(3 = = foo)" rather > >than "if(foo = = 3)" > Ok, I'm new at C, why is the second case less preferable? It seems > counterintuitive. > The first case seems to imply that 3 is the variable, though I know it > can't be. IMHO it's a good indicator because the habit is sort of counter intuitive. Assignment goes from left to right as in "foo = 3;" and, as you observed, "3 = foo" is utter nonsense. If you screw up and forget the second equality symbol in a logical test ("is foo equal to 3" in our example) you will get a clear cut compiler error in the first case (you can't assign a variable to a constent). However, forgetting the eqality sign in the second case results in quietly assigning 3 to "foo" and considering the test met (it evaluates to something non-zero -- namely 3). > For me, it's paranoia brought on by long experience! Well put. When you're looking for proof of experience those habits speak volumes. Someone referred to engineering as like riding a motorcycle. If you get cocky you end up in a ditch... > One thing that seems not to get through in classes, is the critical > difference in comments that tell you what the code is doing (useless, I can > read the code!) and comments that tell you WHY it's doing this. (priceless!). Sounds like you've tried to maintain code! Unless you've had to diddle someone else's code, it's hard to really appreciate what sort of comments will be useful. That shows up in even the most redacted code sample or notebook entry. Win Wiencke Image Logic Corporation _______________________________________________ http://www.piclist.com View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist