Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!spool.mu.edu!munnari.oz.au!brolga!bunyip.cc.uq.oz.au!lance!ptcburp!michi From: michi@ptcburp.ptcbu.oz.au (Michael Henning) Newsgroups: comp.lang.c Subject: Re: When do you use "if ( a = b )"? (was Re: Funny mistake) Message-ID: <357@ptcburp.ptcbu.oz.au> Date: 19 Mar 91 06:25:20 GMT References: <8148@rsiatl.Dixie.Com> <15481@smoke.brl.mil> <775@camco.Celestial.COM> <65837@eerie.acsu.Buffalo.EDU> <1991Mar18.195351.11985@unlv.edu> Organization: Pyramid Technology Corporation Lines: 48 grover@sonny-boy.cs.unlv.edu (Kevin Grover) writes: [ Stuff deleted I entirely agree with ] >Also, if you get bitten but this bug often, try something like > #define EQU == > if ( a EQU b) >Instead of depending upon remembering to use '==' when you need to. NO, NO, NO ! Please don't do this. There is nothing worse than a set of macros that redefine the syntax of the language without achieving anything else. Have you ever seen the original source for the Bourne shell ? It is written with a set of macros that try to make it look like Algol. Almost impossible to understand. Similarly, #defines like #define or || #define and && #define not ! #define begin { #define end } contribute nothing to the readability of the code, but make it worse (IMHO). No matter who hard you try, C is not Pascal. #define EQU == falls into the same category. Granted, using = instead of == is a common mistake, and people do get bitten. If C had used := and == instead, the problem would not exist. Still, things are the way they are, and macros to "improve" the language won't help. Much better to get used to the deficiencies of C and to live with them. Simply say 1000 times: "I shalt never again use = instead of ==". And besides, are you going to change every occurrence of == to EQU in every piece of code you will ever maintain ? I don't think that you would make many friends that way, a lot of software maintenance relies on noise-free diff listings. Michi. -- -m------- Michael Henning +61 75 950255 ---mmm----- Pyramid Technology +61 75 522475 FAX -----mmmmm--- Research Park, Bond University michi@ptcburp.ptcbu.oz.au -------mmmmmmm- Gold Coast, Q 4229, AUSTRALIA uunet!munnari!ptcburp.oz!michi