Archaic, Unusual, and Dangerous Usages
Michael Kupferschmid · 2009
How many different Classical Fortran programs can we write with 7 characters or fewer, not counting blanks? Using the language elements I have covered so far, this is the only one. If we let the source text get longer, the number of character combinations that are syntactically legal and semantically meaningful programs increases very quickly. The total grows even faster if we include the Fortran statements that I have intentionally omitted until now (listed in the Omissions Section of each chapter). For source lengths typical of real applications, the number of possible programs in Classical Fortran is unimaginably huge, though it is dwarfed by the number of legal PL1, C, or Ada programs or, as we shall see in §17.1, by the number of legal Fortran-90 programs. Of course, only a tiny fraction of the possible programs in any language do something useful, and only a tiny fraction of those have the desirable attributes listed in §12.1. In the early days of programming, the teaching of Fortran consisted mainly of reciting the manufacturer’s compiler manual, after which the student was on his or her own to be creative in using the statements, operators, variable types, and logical constructs of the language. The resulting haphazard approach to coding led over the years to the creation of some pretty bizarre programs, many of which are unfortunately still with us and in constant, buggy use. To this day one occasionally hears of a contest to write the strangest possible legal Fortran program, and the results are astonishing, and very funny, to behold [170]. Sadly, many people with more modern training also use Fortran in foolish ways unwittingly, even when they are writing new applications that are supposed to be dead serious. Tomorrow’s nightmare programs are taking shape even as you read these words. In this book, I have tried very hard to select a minimal adequate subset of Fortran and to illustrate only the safest and most civilized ways of using it. By doing this I have revealed to you only a tiny sheltered garden in the vast wilderness of legal coding. As explained in §0.2, Fortran grew wild for a long time and wound up full of bad ideas and idiotic features. Nobody should think of using these things, so I haven’t taught them to you. Some readers may find this paternalistic attitude offensive, and if so I apologize. But it was for your own good. If you’ve gotten this far you are now grown up (though perhaps not yet mature) as a Fortran programmer, so you are entitled to make your own personal variations on the style I suggested in §12.4, and you might decide to use some language features that I have found it prudent to avoid. But please be careful. The power of the Dark Side is seductive, and the penalty for yielding to it is nasty, incorrect, incomprehensible code that you will curse, and for which people will curse you, possibly for decades to come. Beauty may be only skin deep, but ugly, as they say, goes to the bone.