comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <no.spam@no.spam.com>
Subject: Re: Ada exception block does NOT work?
Date: Thu, 18 Aug 2005 14:56:41 +0200
Date: 2005-08-18T14:56:41+02:00	[thread overview]
Message-ID: <de20i9$319$1@sunnews.cern.ch> (raw)
In-Reply-To: <54s1ed.kjh.ln@hunter.axlog.fr>

Jean-Pierre Rosen wrote:

> There are no predefined exceptions in C++

There are.
In particular, creating a new object on the free store can result in 
failure due to inability of the system to allocate memory. This is how 
you create new object on the free store:

int *p1 = new int;
MyType *p2 = new MyType();

etc.

In case of memory allocation error, the above will result in the 
std::bad_alloc exception being thrown.
This is predefined and standard exception in C++.

> 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.
Whether this is good or bad in any particular context is another issue.


>> Why do you claim that Ada's exceptions are "better integrated into the 
>> language than in the languages that throw and catch them"?
> 
> 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?


>> Note that those other languages can throw regular objects as 
>> exceptions
> 
> This boils down to the (controversial) question of how much information 
> should be associated to an exception.
[...]
> So, you see the question is quite open...

Yes, it is and I understand the concerns you mention. But I'm still not 
sure about the "integration with the language" issue. In what way the 
Ada exceptions are more integrated with the language than the C++ 
exceptions (or take any other language from the "throwing" family)?


-- 
Maciej Sobczak : http://www.msobczak.com/
Programming    : http://www.msobczak.com/prog/



  reply	other threads:[~2005-08-18 12:56 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-16  8:48 Ada exception block does NOT work? bubble
2005-08-16  9:00 ` Georg Bauhaus
2005-08-16  9:32   ` bubble
2005-08-16  9:42     ` gautier_niouzes
2005-08-16 15:25       ` Frank J. Lhota
2005-08-16 16:58         ` Svesse
2005-08-16 17:48           ` Björn Persson
2005-08-16 18:12             ` Svesse
2005-08-16 18:17           ` Frank J. Lhota
2005-08-17 10:53         ` Ludovic Brenta
2005-08-17 11:34           ` Anders Wirzenius
2005-08-17 18:08             ` Björn Persson
2005-08-17 19:05               ` Randy Brukardt
2005-08-18 15:58               ` Georg Bauhaus
2005-08-16 12:30     ` Georg Bauhaus
2005-08-16 17:39       ` Björn Persson
2005-08-16 19:43         ` Georg Bauhaus
2005-08-17  1:39     ` Jeffrey R. Carter
2005-08-17  7:22       ` Maciej Sobczak
2005-08-18  1:05         ` Jeffrey R. Carter
2005-08-18  8:44           ` Maciej Sobczak
2005-08-18 11:40             ` Jean-Pierre Rosen
2005-08-18 12:56               ` Maciej Sobczak [this message]
2005-08-18 14:42                 ` Jean-Pierre Rosen
2005-08-18 18:03                 ` Martin Krischik
2005-08-18 13:15               ` Alex R. Mosteo
2005-08-18 15:23                 ` Dmitry A. Kazakov
2005-08-18 18:00                 ` Martin Krischik
2005-08-18 16:13             ` Jeffrey Carter
2005-08-18 16:38               ` Hyman Rosen
2005-08-18 18:07                 ` jimmaureenrogers
2005-08-18 18:44                   ` Hyman Rosen
2005-08-18 20:52                     ` Frank J. Lhota
2005-08-19  0:57                     ` jimmaureenrogers
2005-08-19  7:52                       ` Dmitry A. Kazakov
2005-08-19 14:41                       ` Robert A Duff
2005-08-19 17:48                   ` Martin Krischik
2005-08-19 14:58                 ` Robert A Duff
2005-08-18 17:54             ` Martin Krischik
2005-08-18 20:56             ` Robert A Duff
2005-08-18 22:01               ` Hyman Rosen
2005-08-19  2:35               ` Jeffrey R. Carter
2005-08-20 15:28                 ` Robert A Duff
2005-08-20 20:24                   ` Jeffrey R. Carter
2005-08-20 21:34                     ` Robert A Duff
2005-08-20 22:47                       ` Frank J. Lhota
2005-08-20 23:34                         ` Robert A Duff
2005-08-21 11:18                           ` Simon Wright
2005-08-21 16:59                             ` tmoran
2005-08-21 19:48                               ` Simon Wright
2005-08-21 16:07                           ` Frank J. Lhota
2005-08-21 16:23                           ` Martin Krischik
2005-08-21  1:12                       ` Björn Persson
2005-08-21  9:01                       ` Dmitry A. Kazakov
2005-08-21 16:14                       ` Martin Krischik
2005-08-21  4:02                     ` Larry Kilgallen
2005-08-19 12:34               ` Dr. Adrian Wrigley
2005-08-19 17:29                 ` Martin Krischik
2005-08-19 18:14                   ` Frank J. Lhota
2005-08-21 16:02                     ` Martin Krischik
2005-08-21 16:48                       ` Frank J. Lhota
2005-08-22 15:51                         ` Martin Krischik
2005-08-23  0:32                       ` Larry Elmore
     [not found]                         ` <h5dlg1tsie8n3ikirvbi508t9afobhctkj@4ax.com>
2005-08-23 18:09                           ` Martin Krischik
2005-08-23 19:50                             ` C history Björn Persson
2005-08-27 21:09                             ` Ada exception block does NOT work? Dave Thompson
2005-08-24  1:07                           ` Larry Elmore
2005-08-24  2:36                             ` Jeffrey R. Carter
2005-08-25  0:14                               ` Larry Elmore
2005-08-26  2:44                                 ` Jeffrey R. Carter
2005-08-24 16:44                             ` Martin Krischik
2005-08-22  8:12                     ` Hyman Rosen
2005-08-18 21:15             ` Robert A Duff
2005-08-19 12:00               ` Dmitry A. Kazakov
2005-08-17 20:24 ` Simon Wright
2005-08-18 19:36   ` Björn Persson
2005-08-18 21:07     ` Simon Wright
2005-08-22 10:47 ` bubble
replies disabled

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