J. David Bryan wrote:
Hello Marco,
I have copied my reply to the list.
On 21 May 2000, at 15:56, Marco van de Voort wrote:
Or do they mean:
procedure x;
var i : integer;
procedure nestedx;
begin
i:=5;
end;
begin
for i:=1 to 5 do nestedx;
end;
I believe you are correct, and my original reading that:
i := 0;
for i := 1 to 10 do ;
was incorrect is itself incorrect. The key part of the statement in the
standard is that the "...procedure-and-function-definition part of the
block that closest-contains a for-statement..." cannot threaten the control
variable. In your example, the "procedure x" block (the second begin-end
block) is the "block that closest-contains a for-statement." Therefore,
your first block, that of "procedure nestedx", forms the "procedure-and-
function-definition-part of the block...."
So your example breaks the requirement listed in the standard, meaning your
interpretation is correct. In my example, the threat ("i := 0") is not in
either the for-statement nor the procedure-and-function-definition part, so
it is legal.
I see. So `for' statement are not illegal by themselves in Pascal,
I'm relieved. ;-)
Checking all this seems quite difficult, but at least in principle
possible...
--
Frank Heckenbach, frank@g-n-u.de,
http://fjf.gnu.de/
GPC To-Do list, latest features, fixed bugs:
http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html