Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site watdragon.UUCP Path: utzoo!watmath!watnot!watdragon!cdshaw From: cdshaw@watdragon.UUCP (Chris Shaw) Newsgroups: net.lang Subject: Re: Escape structures (retitled) Message-ID: <865@watdragon.UUCP> Date: Sun, 13-Apr-86 16:39:33 EST Article-I.D.: watdrago.865 Posted: Sun Apr 13 16:39:33 1986 Date-Received: Mon, 14-Apr-86 06:18:32 EST References: <1187@mmintl.UUCP> <6925@cca.UUCP> <> <7040@cca.UUCP> Reply-To: cdshaw@watdragon.UUCP (Chris Shaw) Organization: U of Waterloo, Ontario Lines: 47 The most beautiful way I have seen for directed escape is with the Waterloo System Language's (WSL) GUESS-ADMIT structure. The following details are probably wrong, but you will hopefully get the gist: GUESS : LABEL1 quif( some_condition ) : LABEL1 /* quit guess completely*/ quif( some_other_cond ) /* goto admit */ < processing > ADMIT : LABEL2 /* label optional */ < different processing > ENDGUESS "quif( cond )" means quit the local block if "cond" is true. If a label follows in the quit statement, then the quif goes to the label. One can only go to labels (I recall) at your control statement level or "outer". For example, you can't quit into the body of a non-enclosing WHILE statement. The semantics of quits and quifs are basically gotos which can only branch DOWNWARDS. Therefore, no spaghetti code. This also makes for object code efficiency, since there is rarely a case where one would have to do complicated control structures. The GUESS-ADMIT structure is more or less a thinking person's case statement. ADMITs can be added at will in a GUESS statement. Thus the following could happen (code omitted between each GUESS or ADMIT): GUESS ADMIT :LABEL1 ADMIT :LABEL2 ADMIT :LABEL3 ENDGUESS Each ADMIT block handles one particular situation and no other. One can easily tell by looking what is being done, and it is clear at a glance where control passes to when processing for any ADMIT block is complete. The ADMIT labels allow for quitting past ADMIT blocks that will fail anyway. Hopefully I haven't been too unclear here, but the point I'm trying to make is this: GOTOs are "evil" because they are generally unconstrained in their "scope". The quif/quit structure answers this difficulty by allowing limited scope to where they can transfer control. All control function can be determined at compile time, and the maximum scope available is the surrounding procedure. (I used (and liked) this language a longish while ago. email me for more detail) Chris Shaw watmath!watrose!cdshaw or cdshaw@watmath University of Waterloo Bogus as HELL !!!