| 1 | .....ND "January 1, 1977" |
| 2 | .RP |
| 3 | ....TR 55 |
| 4 | .....TM 76-1273-10 39199 39199-11 |
| 5 | .TL |
| 6 | RATFOR \(em A Preprocessor for a Rational Fortran |
| 7 | .AU "MH 2C-518" 6021 |
| 8 | Brian W. Kernighan |
| 9 | .AI |
| 10 | .MH |
| 11 | .OK |
| 12 | structured programming, control flow, programming |
| 13 | .AB |
| 14 | .ps 9 |
| 15 | .nr PS 9 |
| 16 | .vs 11 |
| 17 | .nr VS 11 |
| 18 | .in 0 |
| 19 | .ll |
| 20 | .PP |
| 21 | Although Fortran is not a pleasant |
| 22 | language to use, |
| 23 | it does have the advantages of universality |
| 24 | and (usually) relative efficiency. |
| 25 | The |
| 26 | Ratfor |
| 27 | language attempts to conceal |
| 28 | the main deficiencies of Fortran |
| 29 | while retaining its desirable qualities, |
| 30 | by providing |
| 31 | decent control flow statements: |
| 32 | .IP "\ \ \ \(bu" |
| 33 | statement grouping |
| 34 | .IP "\ \ \ \(bu" |
| 35 | .UL if-else |
| 36 | and |
| 37 | .UL switch |
| 38 | for decision-making |
| 39 | .IP "\ \ \ \(bu" |
| 40 | .UL while , |
| 41 | .UL for , |
| 42 | .UL do , |
| 43 | and |
| 44 | .UL repeat-until |
| 45 | for looping |
| 46 | .IP "\ \ \ \(bu" |
| 47 | .UL break |
| 48 | and |
| 49 | .UL next |
| 50 | for controlling loop exits |
| 51 | .LP |
| 52 | and some ``syntactic sugar'': |
| 53 | .IP "\ \ \ \(bu" |
| 54 | free form input (multiple statements/line, automatic continuation) |
| 55 | .IP "\ \ \ \(bu" |
| 56 | unobtrusive comment convention |
| 57 | .IP "\ \ \ \(bu" |
| 58 | translation of >, >=, etc., into .GT., .GE., etc. |
| 59 | .IP "\ \ \ \(bu" |
| 60 | .UL return (expression) |
| 61 | statement for functions |
| 62 | .IP "\ \ \ \(bu" |
| 63 | .UL define |
| 64 | statement for symbolic parameters |
| 65 | .IP "\ \ \ \(bu" |
| 66 | .UL include |
| 67 | statement for including source files |
| 68 | .LP |
| 69 | Ratfor |
| 70 | is implemented as a |
| 71 | preprocessor which translates this language |
| 72 | into Fortran. |
| 73 | .PP |
| 74 | Once the control flow and cosmetic deficiencies of Fortran |
| 75 | are hidden, |
| 76 | the resulting language is remarkably pleasant to use. |
| 77 | Ratfor |
| 78 | programs are |
| 79 | markedly easier to write, and to read, |
| 80 | and thus easier to debug, maintain and modify |
| 81 | than their Fortran equivalents. |
| 82 | .PP |
| 83 | It is readily possible to write |
| 84 | Ratfor |
| 85 | programs which are portable to other env ironments. |
| 86 | Ratfor |
| 87 | is written in itself |
| 88 | in this way, |
| 89 | so it is also portable; |
| 90 | versions of |
| 91 | Ratfor |
| 92 | are now running on at least two dozen different types of computers |
| 93 | at over five hundred locations. |
| 94 | .PP |
| 95 | This paper discusses design criteria |
| 96 | for a Fortran preprocessor, |
| 97 | the |
| 98 | Ratfor |
| 99 | language |
| 100 | and its implementation, |
| 101 | and user experience. |
| 102 | .AE |
| 103 | .FS |
| 104 | This paper is a revised and expanded version of oe published in |
| 105 | .ul |
| 106 | Software\(emPractice and Experience, |
| 107 | October 1975. |
| 108 | The Ratfor described here is the one in use on |
| 109 | .UC UNIX |
| 110 | and |
| 111 | .UC GCOS |
| 112 | at Bell Laboratories, Murray Hill, N. J. |
| 113 | .FE |
| 114 | .CS 12 1 13 0 0 10 |