comp.lang.ada
 help / color / mirror / Atom feed
From: eachus@spectre.mitre.org (Robert I. Eachus)
Subject: Re: Help with Exceptions!
Date: 1996/05/14
Date: 1996-05-14T00:00:00+00:00	[thread overview]
Message-ID: <EACHUS.96May14105506@spectre.mitre.org> (raw)
In-Reply-To: 4n9uas$pq0@newsbf02.news.aol.com


In article <4n9uas$pq0@newsbf02.news.aol.com> johnherro@aol.com (John Herro) writes:

  >	I'm not saying that the following is any "better" than the above, but
  > here's how I would do it, without recursion.

  > Retry : Boolean := True;
  > I     : ...     := ...;
  > ...
  > while Retry loop
  >    Retry := False;
  >    while I < ... and not Retry loop
  >	 ...
  >	 if entry_type = continue then
  >	    ...
  >	    Retry := True;
  >	 end if;
  >	 I := ...; -- e.g., I + 1 or ...'Succ(I)
  >    end loop;
  > end loop;
  >	Again, I'm not saying this is better, but my point is that you could
  > "fix" the goto without recursion.

   Your implication is correct, this is a lot worse. ;-) "Fixing" the
flow with state variables either requires at least second loop, two
state variables, multiple settings of the state variable or
duplication of the code for reading the table header.  (In this two
loop variation, you can go back to a for loop for the inner loop since
the continue entry occurs last--if you use are willing to use a loop
exit or return statement to get out in the "normal" case. Otherwise
you need a second state variable.) All of these are abortions that I
wouldn't put in any code I wrote in preference to a single goto and
label.  Not only do the alternatives obfuscate the actual logic, but
some create unexecutable paths through the code that require a lot of
reasoning to verify.  The recursive solution is slightly messy because
you often need four or five parameters in a real parser, but at least
the logic is clean.

--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




  reply	other threads:[~1996-05-14  0:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-05-07  0:00 Help with Exceptions! Robert Gelb
1996-05-07  0:00 ` Steve Howard
1996-05-07  0:00   ` Robert Dewar
     [not found]   ` <4mqio5$a8b@news.sanders.lockheed.com>
1996-05-09  0:00     ` Robert L. Spooner, AD3K
1996-05-10  0:00   ` Jon S Anthony
1996-05-10  0:00     ` Robert A Duff
1996-05-07  0:00 ` John Herro
1996-05-07  0:00 ` Vincent Smeets
     [not found] ` <318F94D9.35AB@io.com>
1996-05-10  0:00   ` George F.Rice
1996-05-13  0:00     ` Dave Jones
1996-05-13  0:00   ` Robert I. Eachus
1996-05-14  0:00     ` John Herro
1996-05-14  0:00       ` Robert I. Eachus [this message]
1996-05-14  0:00   ` Theodore E. Dennison
1996-05-14  0:00     ` Robert A Duff
1996-05-14  0:00 ` Michel Gauthier
1996-05-14  0:00   ` Robert A Duff
1996-05-15  0:00     ` Norman H. Cohen
1996-05-15  0:00       ` Robert A Duff
1996-05-15  0:00 ` Michel Gauthier
1996-05-16  0:00 ` Jon S Anthony
1996-05-16  0:00   ` Robert A Duff
1996-05-16  0:00 ` Jon S Anthony
  -- strict thread matches above, loose matches on Subject: below --
1996-05-09  0:00 tmoran
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox