labelled blocks

ark at alice.UUCP ark at alice.UUCP
Mon Feb 29 12:16:50 AEST 1988


The best scheme I've seen for labelled blocks comes from SETL.
In SETL, statements like `IF' and `WHILE' begin blocks which
must be ended by `END' statements.  Thus one can write:

	IF x > y
	THEN	max := x;
	ELSE	max := y;
	END;

(I think I have the semicolons right; I'm sure about the one after END)

When these structures are nested deeply, one may be confused about
just what is being ended.  To reduce confusion, the programmer may
insert any number of tokens from the opening statement between the
END and the semicolon:

	IF x > y
	THEN	max := x;
	ELSE	max := y;
	END IF x > y;

These tokens are optional, but if they appear, they must match
the corresponding tokens from the opening statement.



More information about the Comp.lang.c mailing list