Re: Ada exception block does NOT work?
- From: Jean-Pierre Rosen <rosen@xxxxxxxxx>
- Date: Thu, 18 Aug 2005 16:42:41 +0200
Maciej Sobczak a écrit :
Certainly depends on which version of C++. I am happy to learn that they eventually made it, but still the language hasn't been designed with exceptions in mind.Jean-Pierre Rosen wrote:
There are no predefined exceptions in C++
There are.
At the time where this policy was decided, there was no exceptions at all. I guess that changing this to raising exceptions would have been too incompatible.therefore things like arithmetic overflow have undefined semantics
The "therefore" part above is not correct. Since there *are* predefined exceptions in C++, dealing with arithmetic anomalies certainly was based on other, unrelated policies.
Well, in C++ you pretty well need to know precisely what code will raise which exception. That's what the syntax says; "try" means: I know that the following code may fail (and conversely, without a "try", I assume it may not fail). Ada is more oriented towards "expecting the unexpected". That's what I meant with the sentence below:Every sequence of statements can have an exception handler in Ada, while in C++/Java/C# you must add an extra level of nesting.
You add the nesting if you want to handle the exception. If you don't want to handle it, you don't add the nesting. This is rather the result of having a *pair* of parentheses to denote a block, with no sensible way of extending this punctuation. In Ada, "begin" and "end" are not a closed pair and are easier to extend with any other keyword, thus making a "comb" of arbitrary length. But this is a syntax issue.
I treat Ada's "begin" as having implicit "try" if there is any handler downstream. Is there anything inherently wrong in this?
This gives the feeling that dealing with exceptions is something you just put in very special places, while in Ada you are more inclined to considering exceptions everywhere.
But then we will drift to discuss whether it makes sense to deal with exceptions everywhere or maybe only where the actual handler has something to do. I haven't seen enough real Ada code to have any opinion what is good in the Ada context.
Don't you do this:
begin -- ... Some_Procedure_That_Might_Raise; -- ... end;
and just let the exception (if any) travel up the chain to where there is enough context to actually *do* somethng with the exception?
Of course.
--
---------------------------------------------------------
J-P. Rosen (rosen@xxxxxxxxx)
Visit Adalog's web site at http://www.adalog.fr
.- References:
- Ada exception block does NOT work?
- From: bubble
- Re: Ada exception block does NOT work?
- From: Georg Bauhaus
- Re: Ada exception block does NOT work?
- From: bubble
- Re: Ada exception block does NOT work?
- From: Jeffrey R. Carter
- Re: Ada exception block does NOT work?
- From: Maciej Sobczak
- Re: Ada exception block does NOT work?
- From: Jeffrey R. Carter
- Re: Ada exception block does NOT work?
- From: Maciej Sobczak
- Re: Ada exception block does NOT work?
- From: Jean-Pierre Rosen
- Re: Ada exception block does NOT work?
- From: Maciej Sobczak
- Ada exception block does NOT work?
- Prev by Date: Re: Ada exception block does NOT work?
- Next by Date: Re: Ada exception block does NOT work?
- Previous by thread: Re: Ada exception block does NOT work?
- Next by thread: Re: Ada exception block does NOT work?
- Index(es):
Relevant Pages
|