Please see below ...
Joe.
-----Original Message----- From: Frank Heckenbach [SMTP:frank@g-n-u.de] Sent: Thursday, June 06, 2002 12:29 PM To: gpc@gnu.de Subject: Re: Pascal-Standard Question
da Silva, Joe wrote:
I've been following this debate and wondering just what the ISO
standards
define. As you know, it's not easy reading through the standards and finding obscure little details such as this. <g>
However, I think section 6.13 of ISO-10206 indicates that a program can indeed consist of multiple modules and can include one main program, each of which is terminated by a "full stop" (aka. "period").
Yes, even in any order. This is rather difficult to handle, if a program precedes a required module. A way to do it is to split the source file and pass each part separately to the compiler. This could be done transparently by a preprocessor, and serve as a (more general) replacement for the current feature ...
[Joe da Silva]
Yes, odd isn't it?
Well, IMHO, if it's too difficult to handle sections (ie. program-components) in any order, it should be an acceptable implementation restriction to require that the main program is the last section (in the usual "define it before you use it" manner).
Also, regarding EOLN and EOF, section 6.7.6.5 indicates that "When eoln(f) is activated, it shall be an error if ... eof(f) is true".
This means, in my words, that it's a runtime error to test EOLn when the file is already at EOF. However, 6.4.3.6 says:
: The structure of the type denoted by text shall define an additional : sequencetype whose values shall be designated lines. A line shall be a : sequence cs~S(endofline), where cs is a sequence of components possessing : the chartype, and endofline shall represent a special componentvalue. : : [...] : : Every value t of the type denoted by text shall satisfy the following two : rules: : : a) If t.M = Inspection, then t.L~t.R shall be a linesequence. : : b) If t.M = Generation, then t.L~t.R shall be ls~cs, where ls is a : linesequence and cs is a sequence of components possessing the : chartype. : : NOTE --- 5 In rule b), cs may be considered, especially if it is nonempty, : to be a partial line that is being generated. Such a partial line cannot : occur during inspection of a file. Also, cs does not correspond to t.R, : since t.R is the empty sequence if t.M = Generation.
This indicates that it doesn't support partial lines at the end of the file except during writing -- whether or not that's a good idea is certainly arguable (I don't really think so) ...
[Joe da Silva]
Yes, the standards seem to consider that a text file must consist of lines and that therefore such a file is invalid (as a text file) if there isn't an EOLN before EOF. Of course, such a file can still be a "file of char", but this means the text file features of read() and write() are lost.
IMHO, the ability of a compiler to handle invalid situations in a more "user friendly" manner, does not truly detract from it's standards compliance, provided this does not affect how it handles valid situations, of course. I consider it a form of "error recovery". Therefore, I see nothing really wrong with a compiler simply returning TRUE for eoln() when eof() is TRUE.
Frank
-- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html