Print

Print


Dan Nagle commented:

! The idea of the F2K draft is that achar( 10) will play the role
! of the single character '\n' in C....
! C text files use '\n'; Fortran formatted stream files use achar( 10).

Actually, it's not the file, but the data processed by the output library
on the way to the file.

! .... One advantage is that vendors may implement Fortran stream files
! using the same library as C fgetc()/fputc()....

I don't see how this works unless the C standard specifies that \n is
ACHAR(10).  If not, anything other than a higher-level abstraction than
ACHAR(10) -- which the vendor would then be free to make \n -- makes this
impossible; the Fortran output routines would need to front-end fputc()
with an ACHAR(10) => \n filter.

fgetc() works because of a curious asymmetry in the current draft of the
Fortran 2000 standard: ACHAR(10) causes new-line during formatted stream
output, but new-line is not specified to cause ACHAR(10) (or anything else)
during formatted stream input.  I have no idea what is expected to happen if
new-line is represented by some junk in a record-mangler database (out-of-
band signalling, to use Malcolm's term).  Since the current draft of the
Fortran 2000 standard is silent on this issue, whatever fgetc() does when it
sees new-line is OK -- a nice portability problem for Dan to add to his
portability project.

If new-line were specified to be read as ACHAR(10) then fgetc() also
wouldn't necessarily work -- the Fortran input library may need to
back-end it with a \n => ACHAR(10) filter.

--
What fraction of Americans believe   |  Van Snyder
Wrestling is real and NASA is fake?  |  [log in to unmask]
Any alleged opinions are my own and have not been approved or disapproved
by JPL, CalTech, NASA, Dan Goldin, George Bush, the Pope, or anybody else.