comp.lang.ada
 help / color / mirror / Atom feed
* Puzzling small piece of code - exception block essentially used as goto
@ 2007-06-02  5:01 Anonymous Coward
  2007-06-02  5:48 ` Jeffrey R. Carter
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Anonymous Coward @ 2007-06-02  5:01 UTC (permalink / raw)


This is an excerpt from some code I recently encountered (it may give
some of you a headache):

  Still_Looping := True;

  Delta_Beyond_Max_Minutes:
    while Still_Looping loop

      Handle_Max_Minute_Error:
        begin

          Hour_Delta    := New_Hour - Hour;
          Still_Looping := False;
          Hour          := New_Hour;

        exception
          when Constraint_Error =>

            if New_Hour > Hour then

              Hour_Delta := Max_Hour_Delta

            else

              Hour_Delta := Relative_Time - Max_Hour_Delta;

            end if;

            Hour := Hour + Hour_Delta;

        end Handle_Max_Minute_Error;
    end loop Delta_Beyond_Max_Minutes;

Tests show that this code actually loops a few times when run in a
typical state.  What I would like clarification on is when the
exception block ends, where is control returned to?

Also, anyone up for the challenge of rewriting this without the
exception handler so the rest of us humans can understand what it's
doing?



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2007-06-08  2:22 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-02  5:01 Puzzling small piece of code - exception block essentially used as goto Anonymous Coward
2007-06-02  5:48 ` Jeffrey R. Carter
2007-06-05  2:38   ` Anonymous Coward
2007-06-05  4:10     ` tmoran
2007-06-05  4:53       ` tmoran
2007-06-02  6:16 ` tmoran
2007-06-05  0:08 ` Adam Beneschan
2007-06-05  7:58 ` anon
2007-06-05 10:40   ` Markus E Leypold
2007-06-05 23:43   ` Anonymous Coward
2007-06-06 10:39     ` Markus E Leypold
2007-06-08  0:55       ` Anonymous Coward
2007-06-08  2:22         ` Markus E Leypold

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