5.  CONCLUSIONS

      Ratfor demonstrates that with modest effort it is possible to convert Fortran from a bad language into quite a good one. A preprocessor is clearly a useful way to extend or ameliorate the facilities of a base language.

      When designing a language, it is important to concentrate on the essential requirement of providing the user with the best language possible for a given effort. One must avoid throwing in ``features'' _ things which the user may trivially construct within the existing framework.

      One must also avoid getting sidetracked on irrelevancies. For instance it seems pointless for Ratfor to prepare a neatly formatted listing of either its input or its output. The user is presumably capable of the self-discipline required to prepare neat input that reflects his thoughts. It is much more important that the language provide free-form input so he can format it neatly. No one should read the output anyway except in the most dire circumstances.

Acknowledgements

      C. A. R. Hoare once said that ``One thing [the language designer] should not do is to include untried ideas of his own.'' Ratfor follows this precept very closely _ everything in it has been stolen from someone else. Most of the control flow structures are taken directly from the language C[4] developed by Dennis Ritchie; the comment and continuation conventions are adapted from Altran[10].

      I am grateful to Stuart Feldman, whose patient simulation of an innocent user during the early days of Ratfor led to several design improvements and the eradication of bugs. He also translated the C parse-tables and YACC parser into Fortran for the first Ratfor version of Ratfor.

References

[1]
B. G. Ryder, ``The PFORT Verifier,'' Software_Practice & Experience, October 1974.
[2]
American National Standard Fortran. American National Standards Institute, New York, 1966.
[3]
For-word: Fortran Development Newsletter, August 1975.
[4]
B. W. Kernighan and D. M. Ritchie, The C Programming Language, Prentice-Hall, Inc., 1978.
[5]
D. M. Ritchie and K. L. Thompson, ``The UNIX Time-sharing System.'' CACM, July 1974.
[6]
S. C. Johnson, ``YACC _ Yet Another Compiler-Compiler.'' Bell Laboratories Computing Science Technical Report #32, 1978.
[7]
D. E. Knuth, ``Structured Programming with goto Statements.'' Computing Surveys, December 1974.
[8]
B. W. Kernighan and P. J. Plauger, Software Tools, Addison-Wesley, 1976.
[9]
B. S. Baker, ``Struct _ A Program which Structures Fortran'', Bell Laboratories internal memorandum, December 1975.
[10]
A. D. Hall, ``The Altran System for Rational Function Manipulation _ A Survey.'' CACM, August 1971.

Appendix: Usage on UNIX and GCOS.

      Beware _ local customs vary. Check with a native before going into the jungle.

UNIX

      The program ratfor is the basic translator; it takes either a list of file names or the standard input and writes Fortran on the standard output. Options include -6x, which uses x as a continuation character in column 6 (UNIX uses & in column 1), and -C, which causes Ratfor comments to be copied into the generated Fortran.

      The program rc provides an interface to the ratfor command which is much the same as cc. Thus

rc [options] files
compiles the files specified by files. Files with names ending in .r are Ratfor source; other files are assumed to be for the loader. The flags -C and -6x described above are recognized, as are
-c compile only; don't load
-f save intermediate Fortran .f files
-r Ratfor only; implies -c and -f
-2 use big Fortran compiler (for large programs)
-U flag undeclared variables (not universally available)
Other flags are passed on to the loader.

GCOS

      The program ./ratfor is the bare translator, and is identical to the UNIX version, except that the continuation convention is & in column 6. Thus

./ratfor files >output
translates the Ratfor source on files and collects the generated Fortran on file `output' for subsequent processing.

      ./rc provides much the same services as rc (within the limitations of GCOS), regrettably with a somewhat different syntax. Options recognized by ./rc include

name Ratfor source or library, depending on type
h=/name make TSS H* file (runnable version); run as /name
r=/name update and use random library
a= compile as ascii (default is bcd)
C= copy comments into Fortran
f=name Fortran source file
g=name gmap source file
Other options are as specified for the ./cc command described in [4].

TSO, TSS, and other systems

      Ratfor exists on various other systems; check with the author for specifics.