Fortran could learn from C

David Hough dgh%dgh at Sun.COM
Sat Feb 20 09:42:09 AEST 1988


The Fortran draft public comment
period is about to close and the C comment period is about to open.

comp.lang.c readers who've been irritated by suggestions that
C could learn some things from Fortran might be slightly
surprised to learn that I suggest that Fortran could
borrow from C as well.   The following excerpts from
the Fortran comments I'm writing relate to C.

Comment #5, Section 3.3:        Source form and  significant blanks

     The Draft should only standardize the modern  free-form
source format with significant blanks, so that newly written
Fortran programs will reflect the  progress  in  programming
language design since Algol-60.

     In addition, to take care of the vast amounts  of  code
in dusty decks, the Draft should require that an implementa-
tion provide means whereby any valid Fortran-66 or  Fortran-
77  program  can be translated automatically to a valid For-
tran 8x program in the free-form source  format.   I  expect
that  a  public-domain  implementation  of such a translator
would soon become available;  a  preprocessor  ought  to  be
incorporated into the standard anyway as discussed next.

Comment #6, Section 3.3:        C preprocessor and #include

     One common complaint about the Draft is  that  is  does
not  provide  an  include-file mechanism; a response is that
include-files are no longer necessary for common definitions
and the like because of the new module interface facility.

     Both the complaint and the response are over-simplified
and  could  perhaps  be  easily resolved if it was more gen-
erally recognized in the Fortran community that  most  large
scientific computing sites have at least some systems with a
tool installed called the C preprocessor, sometimes provided
as  part of a C compiler, sometimes separately.  Its defini-
tion is currently being standardized by X3J11.  An implemen-
tation by the Free Software Foundation is widely available.

     The best course would be to incorporate the  definition
of  the  C  preprocessor into the Fortran 8x draft.  Despite
its many shortcomings, its already  widespread  availability
makes the C preprocessor syntax the choice for providing the
include-file capability, and much more,  in  Fortran.   Most
Unix  systems  already  allow  Fortran  source  files  to be
optionally preprocessed thus.  Its  usefulness  is  somewhat
limited  by  the  restricted line-oriented Fortran-77 source
format, which is another reason why Fortran 8x should decre-
ment that format.

     The Fortran preprocessor  could  also  be  expanded  to
optionally provide the Fortran-66 or Fortran-77 fixed source
format conversion to free form, although that function might
be better left to a separate processor to encourage it to be
done once and for all, rather than on every compilation.

David Hough

ARPA: dhough at sun.com
UUCP: {ucbvax,decvax,decwrl,seismo}!sun!dhough



More information about the Comp.lang.c mailing list