On 19 Oct 2001, at 1:33, Frank Heckenbach wrote:
So, the following program would be allowed to output 0, according to the standard (because i might be mapped to an I/O address that happens to always yield 0)? I strongly doubt it?
Well, you've caught me without my copy of the standard at hand :-), but as I recall, there is a requirement that operations on integers must follow the rules of integer math. I can't check whether assignment is one of those operations listed, but it seems reasonable. So, no, the program you cited wouldn't be a conforming program (pending confirmation from the standard).
But how could the compiler possibly enforce this? Binding to RAM vs. a mapped I/O port (or to ROM) would be done at link time, so must the compiler issue a warning for the "var" statement that variables must be bound to RAM? How else can we disallow such a program?
Moreover, if that I/O address was fully read/write, then the program would be a conforming program (because integer rules would be obeyed), and yet it would still have side-effects without program parameters. That's the only point I was attempting to make.
Yes, but some things (like that the program above should write 42, possibly preceded by a number of spaces) are guaranteed, I think.
Unfortunately, what you and I think has no bearing on the matter. Only what the standard "thinks" is important! ;-) Cite a passage from the standard that states that main program block-level variables may not be bound to external entities, and I will concede your point happily.
This would, in the utmost consequence, mean that any valid Pascal program can do anything, and the standard could be reduced to a syntax diagram.
No, because there are certain semantic requirements in the standard that must be obeyed by conforming programs. However, where the standard is silent, we cannot infer some specific behavior.
It's not mainly about the allocation on physical storage (if a variable is allocated in a file, transparently read and written, that's probably ok), but about (intended) side-effects of seemingly "innocent" variables.
Cite where in the standard such side-effects are expressly prohibited, and I will agree with you. However, if the standard makes no mention of such side effects, we cannot infer that they are prohibited. For example, the standard makes no mention of whether the program code must be executed from ROM or RAM; does that prohibit one or the other?
(By the way, gpc-20010924 does *not* catch this error!)
(dave1.pas)
Thanks!
-- Dave