> A program is a standard-conforming program if it uses only those
> forms and relationships described herein and if the program has
> an interpretation according to this part of ISO/IEC 1539.
>
>So,
>
> READ(*,*) A
> WRITE(*,*) A
> END
>
>we usually say this program is standard-conforming.
Yes, and it is given valid input data.
> But if we
>depend on this program to, say, abort with an error message for a
>non-numeric input value, this program is not standard-conforming??
Correct. The standard does not give the program an interpretation when it is
applied to invalid data.
If the input data is the record
FRED
then it does not satisfy the standard which says (page 263, 10.10.3 paragraph 1
sentence 2):
"The form of the input value shall be acceptable for the type of the next
effective item in the list."
"shall" is a requirement. "FRED" is not an acceptable form for REAL A. End of
story.
One can write programs that don't violate the standard for invalid input, by
having the program do input validation itself (i.e. by reading it into a
CHARACTER variable and checking the format). Admittedly that is pretty tedious
so people rarely bother, either because they "know" that their input is valid,
or because they trust the compiler to generate a nice error code for them. And
most compilers do... but in fact it is not required.
Cheers,
--
................................Malcolm Cohen, Nihon NAG, Tokyo.
|