Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!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: <371@ptcburp.ptcbu.oz.au> Date: 26 Mar 91 23:35:55 GMT References: <1991Mar18.195351.11985@unlv.edu> <357@ptcburp.ptcbu.oz.au> <3130@inews.intel.com> <150@revcan.UUCP> Organization: Pyramid Technology Corporation Lines: 37 darren@revcan.UUCP (Darren Morbey) writes: >Just as a suggestion, what about: > #define EQU(l,r) ((l)==(r)) /*...*/ if( EQU(a,b) ) >I realize this is rather messy, because it >"contribute[s] nothing to the readability of the code." (Mr. Henning) >It does make the equality different from the assignment without violating >"#define should _never_ be used to replace existing tokens." (Mr. Houghton) If you realize that it is rather messy, why do it ? When someone else, who is not familiar with your coding style, gets to see this, he most likely won't know immediately what EQU means, and he will have to go hunting for the macro definition (not always easy if there are a lot of source and header files). What is the point of taking an operator that is already defined in the language and making it look like something else ? >Pardon me for asking, but please define "obfuscation." Your EQU *is* obfuscation, because it replaces something that everyone knows about and can understand (==) with something that no one knows about (EQU). >P.S. I would find it useful to #define NOT(a) !(a), > #define COMPL(a) ~(a), and #define XOR(a,b) ((a)^(b)). > I have trouble remembering the use of the tilde and > circumflex. Again, only a suggestion. If you have trouble remembering !, ~ and ^, then learn them, don't #define them to something else that *you* find easier, but many other people will only find annoying. 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