Path: utzoo!attcan!uunet!lll-winken!lll-tis!mordor!joyce!ames!ucsd!rutgers!njin!princeton!phoenix!pucc!EGNILGES From: EGNILGES@pucc.Princeton.EDU (Ed Nilges) Newsgroups: comp.lang.fortran Subject: Re: Fortran vs C for computations Message-ID: <6065@pucc.Princeton.EDU> Date: 12 Sep 88 18:22:58 GMT References: <962@amelia.nas.nasa.gov> <3290@lanl.gov> <3169@emory.uucp> <1225@scolex> Reply-To: EGNILGES@pucc.Princeton.EDU Organization: Princeton University, NJ Lines: 53 Disclaimer: Author bears full responsibility for contents of this article In article <1225@scolex>, seanf@sco.COM (Sean Fagan) writes: >In article <3169@emory.uucp> platt@emory.UUCP (Dan Platt) writes: >>>#ifdef is an admission that your compiler isn't any good. If the >>>conditional expression is a constant, a normal if statement should >>>be optimized so that code is only generated for the active branch. If >>>the conditional expression is not a constant, it couldn't be used as >>>part of an #ifdef either. >[sorry, don't have the original author's name. Somebody from Los Alamos, I >think] > >This is *wrong*. It sure the hell is. In reference (1), Brian Kernighan says, code what you mean. Macro facilities (even the still-primitive-after-all-these- years facilities of C) allow the software engineer (as opposed to the hacker) to declare an intent to control how the software shall exist in various environments. #ifdef & the macro processor in general allows the C programmer to define a range of potential compilation and execution environments. For example, if I am writing a program to run both on ASCII machines and the IBM 370, which is an EBCDIC machine, the following should be source compatible (altho I have not tested it, and it assumes that either ASCII or EBCDIC will be defined) #ifdef EBCDIC /* Boo */ isalpha = ( inchar>='a' && inchar<='i' || inchar>='j' && inchar<='r' || inchar>='s' && inchar<='z' || inchar>='A' && inchar<='I' || inchar>='J' && inchar<='R' || inchar>='S' && inchar<='Z' ); #endif #ifdef ASCII /* Yay */ isalpha = ( inchar>='a' && inchar<='z' || inchar>='A' && inchar<='Z' ) #endif Indeed, the whole technique of conditional assembly, used heavily within IBM to generate systems across a variety of environments, is so little used in HLLs that a name for it does not roll easily off the tongue. This will be the case until CS departments realize that wisecracks about machines you don't like won't get you off the hook when you have to port your code. When will C have a decent conditional compiler?