Path: utzoo!attcan!uunet!husc6!rutgers!mailrus!ames!amelia!lemming.nas.nasa.gov!fouts From: fouts@lemming.nas.nasa.gov.nas.nasa.gov (Marty Fouts) Newsgroups: comp.lang.fortran Subject: Re: Fortran vs C for computations Message-ID: <962@amelia.nas.nasa.gov> Date: 7 Sep 88 16:24:12 GMT References: <1443@valhalla.ee.rochester.edu> <3256@lanl.gov> Sender: news@amelia.nas.nasa.gov Reply-To: fouts@lemming.nas.nasa.gov.nas.nasa.gov (Marty Fouts) Lines: 46 In article <3256@lanl.gov> jlg@lanl.gov (Jim Giles) writes: > >The same goes for macros. Anything C can do with macros, Fortran can >do with macros. The only difference is that C makes macros part of the >language definition instead of part of the text editing environment >(where it belongs). > I couldn't pass up making a comment here. It has been my experience that using a preprocessor for Fortran macro expansion is a certain way of ensuring nonportable code, since there is no standard preprocessor for Fortran and all implementations are different. Unless you are willing to pull an ADA and require a standard programming environment like the APSE to go with your language, every feature you want for portability must be specified as part of the language standard, making preprocessors/macros a required part of the language definition. As to macros belonging in the language or the text editing environment, I work in an environment where I have macros in both and find I use them differently. I strongly agree with the comment that macros are usually used to overcome deficiencies in the language. As to preprocessors/include files, I have come to strongly depend on them. They are one of the least standard and most frustrating (to me) lacking features in Fortran. I, for one, like the ability to put all of the common parameter statements and common block definitions into a single file and use include directives to make sure that all of my source files get the same version of the common block/parameters. I am also a large fan of using #define and #ifdef in C for conditional compilation. When not overused, this is a major win for smoothing over portability problems and I've missed it many times in trying to make portable programs in Fortran. I also use C macros as a way of achieving inline code expansion, sort of as an efficency hack, but frequently as a way to make unrolled code more readable. This is a personal preference issue, and mine is for readable code at the expense of using the preprocessor to obtain it. Marty +-+-+-+ I don't know who I am, why should you? +-+-+-+ | fouts@lemming.nas.nasa.gov | | ...!ames!orville!fouts | | Never attribute to malice what can be | +-+-+-+ explained by incompetence. +-+-+-+