home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V7 / usr / doc / ratfor / m1 < prev    next >
Encoding:
Text File  |  1979-01-10  |  2.3 KB  |  85 lines

  1. .nr PS 9
  2. .nr VS 11
  3. .if t .2C
  4. .if n .ls 2
  5. .NH
  6. INTRODUCTION
  7. .PP
  8. Most programmers will agree that Fortran is
  9. an unpleasant language to program in,
  10. yet there are many occasions when they are forced to use it.
  11. For example, Fortran is often the only language
  12. thoroughly supported on the local computer.
  13. Indeed, it is the closest thing to a universal programming language
  14. currently available:
  15. with care it is possible to write large, truly portable
  16. Fortran programs[1].
  17. Finally, Fortran is often the most ``efficient'' language
  18. available, particularly for programs requiring much computation.
  19. .PP
  20. But Fortran 
  21. .ul
  22. is
  23. unpleasant.
  24. Perhaps the worst deficiency is in
  25. the control flow
  26. statements
  27. _ conditional branches and loops _
  28. which express the logic of the program.
  29. The conditional statements in Fortran are primitive.
  30. The Arithmetic 
  31. .UC IF
  32. forces the user into at least two statement numbers and
  33. two (implied) 
  34. .UC GOTO 's;
  35. it leads to unintelligible code, and is eschewed by good programmers.
  36. The Logical
  37. .UC IF
  38. is better, in that the test part can be stated clearly,
  39. but hopelessly restrictive because the statement
  40. that follows the
  41. .UC IF
  42. can only be one Fortran statement
  43. (with some
  44. .ul
  45. further
  46. restrictions!).
  47. And of course there can be no
  48. .UC ELSE
  49. part to a Fortran
  50. .UC IF :
  51. there is no way to specify an alternative action if the
  52. .UC IF
  53. is not satisfied.
  54. .PP
  55. The Fortran
  56. .UC DO
  57. restricts the user to going forward in an arithmetic progression.
  58. It is fine for ``1 to N in steps of 1 (or 2 or ...)'',
  59. but there is no direct way to go backwards,
  60. or even (in ANSI Fortran[2]) to go from 1 to
  61. .if n N-1.
  62. .if t N\(mi1.
  63. And of course the
  64. .UC DO
  65. is useless if one's problem doesn't map into an arithmetic progression.
  66. .PP
  67. The result of these failings is that Fortran programs
  68. must be written with numerous labels and branches.
  69. The resulting code is
  70. particularly difficult to read and understand,
  71. and thus hard to debug and modify.
  72. .PP
  73. When one is faced with an unpleasant language,
  74. a useful technique is to define
  75. a new language that overcomes the deficiencies,
  76. and to translate it into the unpleasant one
  77. with a preprocessor.
  78. This is the approach taken with 
  79. Ratfor.
  80. (The preprocessor idea is of course not new,
  81. and preprocessors for Fortran are especially popular
  82. today.
  83. A recent listing [3] of preprocessors 
  84. shows more than 50, of which at least half a dozen are widely available.)
  85.