Path: utzoo!mnetor!uunet!mcvax!tuvie!rcvie From: rcvie@tuvie (ELIN Forsch.z.) Newsgroups: comp.lang.c Subject: Re: labelled blocks Message-ID: <581@tuvie> Date: 7 Mar 88 09:31:41 GMT References: <11702@brl-adm.ARPA> <243@eagle_snax.UUCP> <2245@geac.UUCP> <24996@cca.CCA.COM> <7718@alice.UUCP> Reply-To: rcvie@tuvie.UUCP (Alcatel-ELIN Forsch.z.) Organization: Technical University of Vienna Lines: 50 In article <7718@alice.UUCP> ark@alice.UUCP writes: >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. CHILL (CCITT High Level Language, a realtime application language)has a similar but less confusing syntax: IF x > y max := x; ELSE max := y; FI; There is also somethimg similar to the repetition of the opening statement at the end: Label: BEGIN blah blah END Label; This syntax helps the programmer to find better structures, but unfortunately the compilers cannot use the redundancy for a better recovery. The only advantage are sometimes improved error messages. Besides, studying this language will show anybody who is interested, how a language may be designed in a most horrible way from the compiler writer's point of view (many many keywords, indeterminisms, semantics nobody understands totally, etc.). Dietmar Weickert, ALCATEL-ELIN Research Center, Vienna, Austria.