Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 beta 3/9/83; site sdcrdcf.UUCP
Path: utzoo!linus!vaxine!wjh12!genrad!decvax!ittvax!dcdwest!sdcsvax!sdcrdcf!jonab
From: jonab@sdcrdcf.UUCP
Newsgroups: net.lang
Subject: Re: using gotos
Message-ID: <1114@sdcrdcf.UUCP>
Date: Thu, 31-May-84 08:51:48 EDT
Article-I.D.: sdcrdcf.1114
Posted: Thu May 31 08:51:48 1984
Date-Received: Wed, 6-Jun-84 02:27:20 EDT
References: <1980@mit-eddie.UUCP>
Reply-To: jonab@sdcrdcf.UUCP (Jonathan Biggar)
Organization: System Development Corporation, Santa Monica
Lines: 55

In article <1980@mit-eddie.UUCP> gds@mit-eddie.UUCP (Greg Skinner) writes:
>My feelings on the matter is that those are the only two conditions where a
>goto should be used (when trying to break out of a deeply-nested loop
>and when trying to handle some condition).

You can do both of these in the Ada* Programming Language quite easily
without using a single goto:

EXAMPLE 1:

procedure TEST;
    J: INTEGER;
begin
    ....
    LOOP1: loop
	....
	LOOP2: for I in 1..10 loop
	    ....
	    LOOP3: while j < 10 loop
		....
		exit LOOP1 when j = 5; -- exit all loops if j = 5
		....
		exit LOOP2;  -- unconditionally exit LOOP2
		....
		exit; -- exit innermost loop LOOP3
		....
	    end loop;
	    ....
	end loop;
	....
    end loop;
    ....
end TEST;

EXAMPLE 2:

with TEXT_IO; use TEXT_IO;
procedure COPY_FILE(INPUT: FILE_TYPE; OUTPUT: FILE_TYPE);
    C: character;
begin
    loop
	GET(INPUT, C);
	PUT(OUTPUT, C);
    end loop;
exception
    when END_ERROR =>        -- end of file
	null;                -- we are done, so do nothing
end COPY_FILE;

*Ada is a Trademark of the Ada* Joint Programming Office, Department of
 Defense.

Jon Biggar
{allegra,burdvax,cbosgd,hplabs,ihnp4,sdccsu3}!sdcrdcf!jonab