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 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: tmoran@bix.com Subject: Re: No Go To's Forever! Date: 2000/03/22 Message-ID: <0mVB4.193$2K6.17499@news.pacbell.net>#1/1 X-Deja-AN: 600659756 References: X-Complaints-To: abuse@pacbell.net X-Trace: news.pacbell.net 953688572 206.170.2.239 (Tue, 21 Mar 2000 17:29:32 PST) Organization: SBC Internet Services NNTP-Posting-Date: Tue, 21 Mar 2000 17:29:32 PST Newsgroups: comp.lang.ada Date: 2000-03-22T00:00:00+00:00 List-Id: > look_ahead(in_file,ch,bool); > <> > 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; How about: loop look_ahead(in_file,ch,got_eol); if got_eol then skipline(infile); elsif ch = ' ' get(infile, ch); else exit; end loop; It's shorter, the logic of what's going on is clearer, only a single line needs to be changed to add tab skipping, there's only one way to enter the code sequence (no distant "goto start") so the first reference to bool or ch is guaranteed to come *after* the look_ahead call that sets their values, and, since the compiler can tell the control flow, it can do better optimization. >I realize everything is posible to do without gotos >but I canot figure out why it is so horible. A piece of logic expressed with loops, ifs, cases, and subroutine calls is almost always clearer (and therefore less likely to be erroneous) and is commonly also shorter than the (attempted) equivalent using goto. In MSDOS .bat and assembler you have no choice but to use a jump/goto. Your toolset is bigger now, learn to use it. >I know it might make the program hard to follow, but I don't care! But a hard to follow program is hard to debug and hard to extend, and therefore worth less.