"RATFOR" stands for "RATIONAL FORTRAN." It endows FORTRAN with a C-like syntax. Certain loop and other constructions (such as `switch' or `i++') that are not allowed in FORTRAN are allowed in RATFOR; @FWEB{} translates those into proper FORTRAN.
Although RATFOR is a definite improvement over FORTRAN, it certainly does not have the power of C (e.g., elegant pointer notation) or C++ (e.g., classes). Many advantages accrue by taking the time to learn C. RATFOR offers a gentle transition. (It is not supported very actively any more.)
A sample RATFOR program is
@r @ @a program main { integer k; real fcn, x; for(k=0; k<10; k++) { x = fcn(k); if(x < 0.0) { x = 0.0; break; } } }
The concluding brace of a function is translated into an END statement. Note the use of semicolons to terminate statements, braces to delimit compound statements, `<' instead of `.LT.', the C-like for construction, and the `k++' expression.
Constructions like `k++' or `k -= l + 1' must be used with great care. They translate to statements involving `=' signs, so they can be used only where simple statements are allowed, not essentially anywhere as in C (for example, they cannot be used as function arguments).
break; // Used withcase
or to break out of loops, as in C. case i: // Used withswitch
. default: // Used withcase
, as in C. do ...; {...} // Note the semicolon (unnecessary if followed by a compound stmt). else {...} // Used afterif
as in C. for(a;b;c) {...} // As in C. if(condition) {...} next; // Equivalent to C's |continue| statement; go to bottom of loop. repeat {...} until(condition); // Equivalent to C'sdo {...} while();
return expression; // As in C. switch(expression) {...} // As in C. while(condition) {...} // Like C'swhile
.
contains: interface name {...} interface operator(op) {...} interface assignment(assgnmnt) {...} module name {...} private: sequence: type name {...} where(expression) {...}
The version of RATFOR built into @FWEB{} differs slightly from its UNIX counterpart:
- Numeric statement labels must be followed by a colon; they should be first on their line. (Use symbolic statement labels instead; see the discussion of `#:0' in section Special tokens.)
- The quoting convention for characters and strings follows that of C: Single-quote single characters, double-quote strings.
- In a switch, cases fall through to the next case unless terminated by break (just as in C).
- The do statement must be terminated by a semicolon if followed by a simple statement. (It's unnecessary if followed by a left brace that begins a compound statement.)
- Use && and || for the logical AND and OR.
- Do not use an end statement at the very end of a RATFOR program unit; it is added automatically by @FWEB{} when the closing brace is sensed.
Go to the first, previous, next, last section, table of contents.