On Jun 11, 2007, at 2:14 PM, Micha Nelissen wrote:
Gale Paeper wrote:
In abstract terms, the statements in the statement-sequence of that compound-statement are:
if-statement goto-statement
I see. The following is then also not allowed ? Assume, i, j, l, h, k, m integers, foo a label.
for i := l to h do begin for j := k to m do begin writeln(j, ' '); goto foo; end; foo: writeln('hello'); end;
It is a ISO Pascal legal goto statement. Remember there are three conditions and all that is necessary if one of the conditions is satisfied. In this example, condition b) "S is a statement of a statement-sequence containing G." is satisfied so the foo label is a valid label for the goto statement. (Ignoring for the moment that "foo" isn't an ISO Pascal legal label.)
"foo: writeln('hello');" is a statement in the "for i..." compound- statement statement-sequence. The "for j ..." statement is also in that statement-sequence and the "goto foo;" statement is contained (through the containing compound-statement) by that for-statement. So, with the "goto foo;" statement, the foo label is prefixing a statement of a statement-sequence which contains (through several containing levels) the goto-statement. Thus, condition b) is satisfied and "foo"" is a legal label target for the goto statement.
Gale Paeper gpaeper@empirenet.com