From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,14f7200925acb579 X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: No Go To's Forever! Date: 2000/03/22 Message-ID: <8b93n3$8ai$1@nnrp1.deja.com>#1/1 X-Deja-AN: 600631474 References: <38D7B41D.B3494C6A@lmco.com> <38D7B83B.27DC06C8@earthlink.net> X-Http-Proxy: 1.0 x28.deja.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Wed Mar 22 00:22:09 2000 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.61 [en] (OS/2; I) Date: 2000-03-22T00:00:00+00:00 List-Id: In article , =?ISO-8859-1?Q?Tim_Gahnstr=F6m?= wrote: > I realize everything is posible to do without gotos > but I canot figure out why it is so horible. > Please enlighten me. > Is goto statments particular slow? > > Tim Gotos often make simple code hard to read. Your example is a good one! <> while bool loop skipline(infile); look_ahead(in_file,ch,bool); end loop; if ch=' ' then while ch=' ' loop get(infile,ch); look_ahead(in_file,ch,bool); end loop; goto start; end if; The following is preferable in every way. It makes the exit condition from the outer loop far clearer (not to mention making it clearer that there *is* an outer loop! loop while bool loop skipline(infile); look_ahead(in_file,ch,bool); end loop; exit when ch /= ' '; while ch=' ' loop get(infile,ch); look_ahead(in_file,ch,bool); end loop; end loop; It is shorter and clearer. <> No, the concern is not for efficiency at all! There are (rare) cases where gotos are appropriate, but they are few and far between, and your example is a good one showing why gotos should not generally be used. In fact gotos are so often misused that some people go to the extreme of saying they should never ever be used. This approach is excessive, but has the advantage of completely eliminating the kind of misuse you illustrate in your example. Sent via Deja.com http://www.deja.com/ Before you buy.