Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!rpi!bu.edu!purdue!iuvax!bomgard From: bomgard@iuvax.cs.indiana.edu (Tim Bomgardner) Newsgroups: comp.lang.c Subject: Re: Assignment in test: OK? Message-ID: <57945@iuvax.cs.indiana.edu> Date: 11 Sep 90 16:38:42 GMT References: <1990Sep7.042759.3804@ux1.cso.uiuc.edu> <3836@se-sd.SanDiego.NCR.COM> Organization: Indiana University, Bloomington Lines: 25 In article <3836@se-sd.SanDiego.NCR.COM> rns@se-sd.SanDiego.NCR.COM (Rick Schubert) writes: }In <1990Sep7.042759.3804@ux1.cso.uiuc.edu> gordon@osiris.cso.uiuc.edu (John Gordon) writes: } }> One way to avoid the =/== pitfall is to write your code like this: } }> if(7 == x) rather than if(x == 7). } }> If you write it the first way, and accidentally write = instead of ==, }> you will be trying to assign a value to a constant (!!) and will get }> an error. } }I have seen this suggestion in this newsgroup quite a few times in the past }and I always wonder: } } If you remember to put the constant on the left, won't you also remember }to use `==' rather than `='? } }[Personally, I think `if(7 == x) is ugly.] } }-- Rick Schubert (rns@se-sd.sandiego.NCR.COM) I agree, 'if(7 == x)' is ugly. It makes me stop, back up, and reread. My conditionals all look like Fortran: 'if (x EQ 7 OR y LT 3)'. Guess you can tell where *I* grew up. Haven't had a problem in years, except once from someone who was reusing some of my code.