Path: utzoo!attcan!uunet!cs.utexas.edu!samsung!sdd.hp.com!hplabs!hpda!hpcupt1!jamiller From: jamiller@hpcupt1.HP.COM (Jim Miller) Newsgroups: comp.lang.c++ Subject: Re: Bogus pure macro (was: Re: #defines....) Message-ID: <7050024@hpcupt1.HP.COM> Date: 10 Jul 90 20:45:05 GMT References: <688@dyndata.UUCP> Organization: Hewlett Packard, Cupertino Lines: 62 >IMHO, the point is not to duplicate *precisely* what can be >done with macros, but to write clear, concise, efficient code -- >code which can be understood and maintained easily. So I must >ask whether these macro examples fit these criteria better than >other C++ language mechanisms. >-- > >Steve Clamage, TauMetric Corp, steve@taumet.com >---------- 1. How do you handle portability problems with MS-DOS (the "near" and "far" example) and other machine dependent features without #defines? I agree that doing things "differently" is not necessarily "bad", but how do you write portable "write clear, concise, efficient code -- code which can be understood and maintained easily" without macros? Please, use this example for discussion, not some other straw man (other straw men are ok, just hit this one while you are at it). /* from Walter Bright's response */ #if !(MSDOS || __OS2__) #define cdecl #define near #define far /* make extended keywords go away */ #endif int near function() { ... }; 2. conditional compiles It is NOT a "bad practice", so what is the best C++ way ? 3. Debugging (from Daniel_Gregory_Corbett's response) #define DEBUG /* This might be defined on the command line */ /* using -DDEBUG */ #ifdef DEBUG printf("Debug Statement i=%d\n", i); #endif I don't think the above examples are "syntax abstraction", and they are EXTREMELY useful in writing *correct* "clear, concise, efficient code -- code which can be understood and maintained easily". While they often do subtract from the "clear and concise" the improvement in "correct and portable" is overwhelming IMHO. jim - inquiring minds would like to know - miller My company does not even know I have an opinion, let alone approve of it. ................... By the way folks, does ARM stand for "The Annotated C++ Reference Manual", and if so why isn't it ACRM or AC++RM or TACRM or . . . ? Anyway, references to ARM confused me for a while, and it might others, it's not (yet) as common as K&R.