Clive Page writes:
> I don't see what was wrong about it, I wasn't confusing internal and
> external representations, just listing what exists in a text file on the
> three families of operating systems.
What exists in a text file is the external representation. The
proposed achar(10) (or the C '\n') is the internal representation.
The whole point of the feature in question is that the two do not have
to be the same.
> Yes, I think even I could write code to do that. But this worries me. Are
> you saying that in Fortran 2002 the run-time system will scan the stream
> of characters being written and replace every instance of character 10
> decimal, however produced, with a pair of chars 13, 10 (decimal again) in
> a program running under an operating system (such as Windows) where CR,LF
> is the "newline" marker?
Yes. Absolutely. (For formatted stream only - this isn't for
formatted sequential, which remains as it is). I don't know why you
are so surprised. This is *EXACTLY* what C does. Implementation is
not difficult or costly. Indeed, since this is the same as what C
does, some Fortran implementations are likely to get it for "free"
by just using existing C facilities. You might actually have to
do some work to avoid it (though I'm not sure of that part).
Note that stream I/O was introduced as a C interop feature. That
doesn't mean we should blindly follow every mistake that C might have
made. But it does suggest that there is a lot of sense to going
along with things that do seem to work well.
Indeed, C interop is one of the reasons I like this. There are likely
to be codes that expect to be able to take *THE SAME* internal
character string, including an internal newline representation, and
have it work the same way when written to a file on multiple systems.
You don't want to have to change the internal data depending on what
system it runs on. Having a parameter to tell you what it needs
to be on each system isn't nearly as good as not having to change it
at all for different systems.
> Are there other substitutions, e.g. achar(0), or achar(26)?
No.
--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
| -- Mark Twain
|