Fortran

From: Andreas Freiherr <Andreas.Freiherr_at_Vishay.com>
Date: Fri Feb 28 14:23:00 2003

About APL, ...

Eric Smith wrote:
> It most certainly does have syntax, though it's quite simple.
> And it's quite easy to get syntax errors. But because most characters
> can serve as both monadic and dyadic functions, it's also possible to
> have a typo that is valid syntax but does something quite different
> than what you intended.

So this is not a syntax question, but a semantic one. Similar with
FORTRAN: assume you wanted to write

       DO 20 I = 1,5
         WRITE (LUNUTO, 10)
10 FORMAT (' Hello world!')
20 CONTINUE

which happens to be a loop that outputs the text from the FORMAT
statement five times, but put the first line slightly wrong like

       DO 20 I = 1.5

then this line does not start a loop any more, but becomes a simple
assignment to a variable named DO20I, implicitly typed as REAL. This
happens because FORTRAN is, by definition, blind to spaces (!), except
in string constants.

Incidentally, many FORTRAN compilers require that the comma is on the
first line of a DO statement, while anything beyond it is allowed to be
on continuation lines.

Decades ago, I used to have a demo program that contained lots of things
like this, and whenever somebody claimed to be an experienced FORTRAN
programmer, I asked them to predict the output. Nobody ever got it right
completely.

Of course, many of the surprises were implementation dependant, and it
was impossible to port the program from TOPS-10 to VAX/VMS. The above
example, however, *is* portable. Just make sure LUNUTO (logical unit for
user terminal output) has a value that is appropriate for your favorite
operating system/compiler combo (e.g., for TOPS-10, LUNUTO=5, for VMS
LUNUTO=6).

--
Andreas Freiherr
Vishay Semiconductor GmbH, Heilbronn, Germany
http://www.vishay.com
Received on Fri Feb 28 2003 - 14:23:00 GMT

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:35:57 BST