comp.lang.ada
 help / color / mirror / Atom feed
From: iloAda <egzgheib@gmail.com>
Subject: Re: Forcing Exception Handling
Date: Tue, 1 Mar 2011 01:34:02 -0800 (PST)
Date: 2011-03-01T01:34:02-08:00	[thread overview]
Message-ID: <91988389-b17a-42cb-8f5b-9b1205604b55@y3g2000vbh.googlegroups.com> (raw)
In-Reply-To: 195bsgigtzacu$.13u18z09ptrtw$.dlg@40tude.net

On Mar 1, 9:56 am, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
> On Mon, 28 Feb 2011 16:19:22 -0800 (PST), Shark8 wrote:
> > In fact, given that Ada doesn't have an "exception hierarchy" like
> > Delphi does it may be a horrendous idea: There is no way to catch all
> > exceptions because there is no way to catch a  all exceptions of a
> > certain type (i.e. Storage_Error'Class) which is caused by the lack of
> > some root-type "Exception_Root."
>
> It is a question. Since exceptions are used in case-like clauses, more
> natural where a model of a discrete type. In order to have constructs like:
>
>    when Numeric_Exception'First..Numeric_Exception'Last =>
>
> BTW, it shows the importance of extensible enumeration types, because
> exceptions should be that kind of type.
>
> When exceptions are bunch of types like in C++ you would loose the above.
>
> Also consider this:
>
>    declare
>       Foo : exception:
>    begin
>       ...
>       raise Foo;
>    end;  -- Foo propagates out its scope!!
>
> Unless Ada would have upward closures, that cannot work when Foo is a type.
> I hope everybody agrees that upward closures should not be introduced.
>
> A possibility to handle this is exception promotion, e.g. Foo to
> Program_Error, when Foo gets finalized.
>
> BTW, contracted exception would solve this problem by making such programs
> illegal: each block would have an implicit contract not to propagate local
> exceptions.
>
> --
> Regards,
> Dmitry A. Kazakovhttp://www.dmitry-kazakov.de

Mmmmmm...That's what I was fearing!!
Actually the idea behind my question was that I'm working on a real
time system, and as u know, we can't afford to a let a real time
system crash because of an unhandled exception. Since I use some other
libraries in my system (that weren't written by myself or anybody else
I know) that will raise exceptions, I wanted to be forced to handle
them. I was imagining that it could be done with some kind of a
compiler pragma that will force the current package to handle all
exception that may be raised, but as u guys pointed out, the compiler
might not be able to know which procedure raises an exceptions (by
contrast java requires the addition of the "throws" instruction which
tells the compiler what's gonna happen)
One solution might be to just put the following code everywhere (even
though I don't like this):

exception
 When others =>
     --  Do something that will allow the system to keep on running

have u guys done something like that before?

thanks



  reply	other threads:[~2011-03-01  9:34 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-28 17:27 Forcing Exception Handling iloAda
2011-02-28 17:32 ` Simon Clubley
2011-02-28 18:33   ` onox
2011-02-28 19:10     ` Simon Clubley
2011-02-28 18:34   ` Vinzent Hoefler
2011-02-28 20:20 ` Florian Weimer
2011-02-28 20:35 ` Ludovic Brenta
2011-03-01  3:54   ` Randy Brukardt
2011-03-01  8:34     ` Dmitry A. Kazakov
2011-03-02  0:00       ` Randy Brukardt
2011-03-02  8:28         ` Dmitry A. Kazakov
2011-02-28 20:38 ` Georg Bauhaus
2011-03-01  0:19   ` Shark8
2011-03-01  8:56     ` Dmitry A. Kazakov
2011-03-01  9:34       ` iloAda [this message]
2011-03-01  9:47         ` Vinzent Hoefler
2011-03-01  9:51         ` Dmitry A. Kazakov
2011-03-01 10:07           ` iloAda
2011-03-01 13:27         ` Mark Lorenzen
2011-03-01 16:11         ` J-P. Rosen
2011-03-02  0:11         ` Randy Brukardt
2011-03-01 15:23       ` Shark8
2011-03-01 15:44         ` Dmitry A. Kazakov
2011-03-02  0:02       ` Randy Brukardt
2011-03-01  2:08 ` Hoàng Đình Long
2011-03-02 13:39 ` ytomino
replies disabled

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