comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Ada exception block does NOT work?
Date: 19 Aug 2005 10:58:32 -0400
Date: 2005-08-19T10:58:32-04:00	[thread overview]
Message-ID: <wcc8xyy6kiv.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 1124383129.977718.320820@g44g2000cwa.googlegroups.com

"Hyman Rosen" <hyman.rosen@gmail.com> writes:

> Jeffrey Carter wrote:
> > The try/catch block is one such symptom.
> 
> No. It would have been perfectly possible to not have
> 'try' at all, and simply allow a sequence of catch
> clauses to follow any statement. Bjarne Stroustrup
> addresses this explicitly in _The Design and Evolution
> of C++_. The problem was that the resulting code looked
> ambiguous and difficult to understand. Having explicit
> try and a brace-enclosed section enhanced readability.

I agree with Hyman Rosen here (and with Bjarne Stroustrup!).

Not only is it more readable to have a separate statement for handled
regions, it simplifies the language.  And it obviates the need for
extraneous block_statements.

On the other hand, it's not that big of a deal, either way.

> > That the C++ core language tends to have undefined/
> > implementation-defined semantics where Ada has semantics
> > defined in terms of exceptions is another.
> 
> The designers of C++ simply followed the lead of their
> parent language in not checking certain core operations.
> The choice was made not to check, so debating which
> mechanism would not be used to not report the error is
> silly. Where C++ does require checks, generally exceptions
> are raised on failure. (Formatted I/O allows the choice to
> silently fail subsequent operations once one fails, and
> then to check once for failure at the end.)

OK, fair enough.  But I still think allowing the programmer to choose
whether to do overflow checking or not is a far superior language design
than one that doesn't allow that choice.  The programmer, not the
language designer, is the only one in a position to make that choice.

> > On a more concrete level, Ada's was initially intended for critical,
> > real-time, embedded SW. Allowing an arbitrary object to be used
> > as/associated with an exception in such systems may not be a good idea.
> 
> But as we know from SPARK, use of Ada in such environments
> generally involves throwing away much of the existing language.
> Therefore I do not find this to be a valid argument.

I don't find it to be valid, either.  But I think your point about SPARK
is invalid, too, because many real-time embedded systems use much larger
subsets of Ada than SPARK.

The real issue is whether exception (occurrences) can have non-static
size.  If that's bad for your real-time system, then don't use that
feature; it's not a good reason to leave the feature out of the
language.  Another case where the programmer, not the language design,
should make the decision.

> > Additionally, Ada allows nested scopes, which C and its descendants do
> > not. This allows the existence of anonymous exceptions, exceptions that
> > have propagated out of the scope of their definitions. Allowing
> > arbitrary objects as/associated with exceptions gives rise to a similar
> > set of problems as allowing type extensions at a deeper scope than the
> > parent.
> 
> Yes, that's a much better argument. It puts the cause squarely on
> other aspects of Ada's design rather than harrumphing and handwaving.
> By the way, it's not correct to say that Ada allows nested scopes and
> C-like languages do not. The problem here is that in Ada types are
> dynamic while in C-like languages all types are static regardless of
> the scope in which they are defined. So in those languages, there is
> no concept of an object being able to outlive its type, and thus no
> problem with throwing it out of the scope in which the type was
> defined.

But in both C++ and Ada, types have type descriptors (or method dispatch
tables, or whatever you want to call them).  These point at procedures.
And if those procedures can be nested, those procedures can depend on
(and modify) the stack-allocated data.

In other words, I agree with Jeff here, that the issue is nesting (not
staticness of types).

- Bob



  parent reply	other threads:[~2005-08-19 14:58 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
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 [this message]
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