On Sun, 08 Jun 2008 09:47:30 +0300, Niklas Holsti wrote:
> The solution is just to add one more "begin..end" block, enclosing
> the "declare .. begin .. end", and handle the exceptions in this
> outer "begin..end" block. Or handle the exceptions in the
> subprogram's "begin..end" block and nest the "declare..begin..end"
> within the subprograms "begin..end".
>
> That said, I admit that I, too, have made this mistake once or
> twice. But not lately.
If exceptions were contracted such, quite nasty, errors could be detected
at compile time.
> I wonder if it would be a good idea for Ada to allow an exception
> handler also in the "declare" part, as follows:
>
> -- NOT Ada!
> declare <some variables>
> exception <handle exceptions raised in the declarations>
> begin <some statements>
> exception <handle exceptions raised in the statements>
> end;
>
> Of course, in this proposal the declaration-exception handler would
> not have access to the declared variables.
But then, for regularity sake, you would need to add exception handling to
all declarative parts:
package A is
<some declarations>
exception
<handling elaboration problems of A, HOW?> (:-))
end A;
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


|