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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,803d147296719896,start X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!out01b.usenetserver.com!news.usenetserver.com!in02.usenetserver.com!news.usenetserver.com!cycny01.gnilink.net!spamkiller2.gnilink.net!gnilink.net!trndny07.POSTED!f0d9c8c1!not-for-mail Newsgroups: comp.lang.ada From: Anonymous Coward Subject: Puzzling small piece of code - exception block essentially used as goto User-Agent: slrn/0.9.8.1 (Linux) Message-ID: Date: Sat, 02 Jun 2007 05:01:15 GMT NNTP-Posting-Host: 72.86.114.139 X-Complaints-To: abuse@verizon.net X-Trace: trndny07 1180760475 72.86.114.139 (Sat, 02 Jun 2007 01:01:15 EDT) NNTP-Posting-Date: Sat, 02 Jun 2007 01:01:15 EDT Xref: g2news1.google.com comp.lang.ada:16044 Date: 2007-06-02T05:01:15+00:00 List-Id: 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?