Re: Ada exception block does NOT work?



dear Georg:
thank to your reply so quickly.
and the problem still not be sloved.

you can test "test code".
you will find some thing interesting.


the statement , Avg := Sum / Data'Length;
should be throw a exception signal when Data'length is 0 (empty array)
and then the exception block handler should catch the signal, and do some
recovery process.

in the test case, it doesn't work
in first exceptin case, Ada throw a exception and transfer the control to
exception handler (greater).
in 2nd exception case,Ada "should" throw exception and do control transfer.
Unfortunately, it does not do.



> bubble wrote:
>
>> I found Ada can not re-enter the exception block twice.(oh! my god)
>> It should be work.
>
> It does :-). Reentering means to loop, so you could write,
> in your procedure's body
>
> loop
> begin
> some_computation(data);
> exit retrying;
> exception
> when Some_Exception =>
> report;
> make_adjustments;
> end;
> end loop;
>
> or
>
> retry: loop
> begin
> some_computation(data);
> exit retry;
> exception
> when Some_Exception =>
> report;
> make_adjustments;
> end;
> end loop retry;


.



Relevant Pages

  • Re: long double versions of functions in gcc under Cygwin
    ... rather than the nearest enclosing one) and a decent exception ... them it doesn't seem like goto usage would be affected ... int typfun() ... Why use a for loop when it is just a while loop in disguise? ...
    (comp.lang.c)
  • Re: CInternetSession
    ... the presence of the Sleepindicates the serious design flaw. ... Sleep() calls around like pixie dust, your design is fundamentally broken and will need to ... If you use Sleepin a loop, your design is probably wrong and needs to be ... The "First Chance Exception" message usually indicates nothing harmful. ...
    (microsoft.public.vc.mfc)
  • Re: Get_Line problem (GNAT bug?)
    ... Now, if the program specs says: "read the lines from input until EOF", then this for me immediately translates into a loop with some exit condition. ... "Read until" - you have a regular end-of-sequence condition here. ... I'm not convinced that exception might be a correct design choice for breaking the loop that reads data from well formatted file. ...
    (comp.lang.ada)
  • Re: TextOut() to a DialogBox ???
    ... Do you know the "guard page" trick? ... significant cost of the entire loop. ... So the trick is to put an unreadable page just ... This is a value which tells the stack unwinder what to do, it is itself, not an exception. ...
    (microsoft.public.vc.mfc)
  • Re: long double versions of functions in gcc under Cygwin
    ... missing feature in the language. ... named break (which could be used to break out of a specified loop ... rather than the nearest enclosing one) and a decent exception ... goto just operates on the control flow of your program. ...
    (comp.lang.c)