Path: utzoo!utgpu!news-server.csri.toronto.edu!torsqnt!lethe!druid!darcy From: darcy@druid.uucp (D'Arcy J.M. Cain) Newsgroups: comp.lang.c Subject: Re: Assignment in test: OK? Message-ID: <1990Sep14.135655.18015@druid.uucp> Date: 14 Sep 90 13:56:55 GMT References: <1990Sep7.042759.3804@ux1.cso.uiuc.edu> <3836@se-sd.SanDiego.NCR.COM> <57945@iuvax.cs.indiana.edu> Organization: D'Arcy Cain Consulting, West Hill, Ontario Lines: 27 In article <57945@iuvax.cs.indiana.edu> bomgard@iuvax.cs.indiana.edu (Tim Bomgardner) writes: >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 remember to put the constant on the left, won't you also remember >}to use `==' rather than `='? >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. Which is the problem with that sort of code. You can't give C code disguised as FORTRAN to a C programmer and expect them to be comfortable with it. I like to do the following; if ((x = 7) != 0) It makes the intention perfectly obvious to any other C programmer and most compilers will optimize it anyway. The Borland compiler has settings that flag the 'if (x = 7)' construct as a warning and I use this on the DOS side. It has caught a few typos for me. -- D'Arcy J.M. Cain (darcy@druid) | D'Arcy Cain Consulting | MS-DOS: The Andrew Dice Clay West Hill, Ontario, Canada | of operating systems. + 416 281 6094 |