stringfilestandardspascaliso

Standard Pascal 7185 silent on reading strings from textfiles


In the ISO/IEC 7185:1990(E) Standard Pascal specification, in Clause 6.9.1 for the procedure read, subsection "a)" reads as follows:

a) For n>=1, read(f,v1,...,vn) shall access the textfile and establish a reference to that textfile for the remaining execution of the statement; each of v1,...,vn shall be a variable-access possessing a type that is the real-type, is a string-type, or is compatible with the char-type or with the integer-type. For n>=2, the execution of read(f,v1,...,vn) shall be equivalent to

begin read(ff,v1); read(ff,v2,...,vn) end

where ff denotes the referenced textfile.

It lists allowable types for the variable parameters as: real, string, and types compatible with char or integer.

However, the remainder of the clause doesn't specify the behaviour for string-types. Subsection "b)" covers type char, subsection "c)" covers type integer, subsection "d)" covers type real, but there is no further mention of strings.

I find this odd, since the corresponding procedure write does specify the behaviour for strings in Clause 6.9.3.6 when describing what its parameters do. The intent seems to be to allow one to read strings from textfiles directly into a variable-access having a string-type, since otherwise why mention it at all in Clause 6.9.1?

Is this a bug in the spec, or am I reading it wrong?


Solution

  • I believe this is an erratum stemming from authoring ISO 10206 at the same time (although 10206 was approved later). The preface of ISO 10206 Extended Pascal says:

    Technical development

    Extended Pascal incorporates the features from ANSI/IEEE770X3.97‑1983 and the following new features: […]

    • The procedure read has been extended to read strings from textfiles.

    Highlighting this as a new feature suggests that ISO 7185:1983 did not have said capability.

    Furthermore, Kathleen Jensen and Niklaus Wirth write in Pascal – user manual and report (4th revised ed.) (10.1007/978-1-4612-4450-9), § 12.1 Read of part Pascal report:

    When using Read on a textfile, the following rules apply. Let f denote a textfile, and let v1, …, vn denote variables possessing type Char or Integer (or subrange of either) or Real.

    No word on reading from a text file into a string variable. The PUMAR 4th ed. restates ISO 7185:1990.

    Finally, concededly it’s a weak point, but the GNU Pascal Compiler refuses to read into string variable in ‑‑standard‑pascal mode. The developers of the GPC have done a great job at adhering to the ISO standards as good as possible, so I have faith they properly interpreted said section correctly, too.