comp.lang.ada
 help / color / mirror / Atom feed
From: anon@anon.org (anon)
Subject: Re: Puzzling small piece of code - exception block essentially used as goto
Date: Tue, 05 Jun 2007 07:58:49 GMT
Date: 2007-06-05T07:58:49+00:00	[thread overview]
Message-ID: <ZI89i.107390$p47.52904@bgtnsc04-news.ops.worldnet.att.net> (raw)
In-Reply-To: vQ68i.99$UD4.49@trndny07


Looks like a HOMEWORK problem to me:
And I do not help students cheat!

In <vQ68i.99$UD4.49@trndny07>, Anonymous Coward <anonymous@coward.org> writes:
>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?




  parent reply	other threads:[~2007-06-05  7:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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
replies disabled

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