Re: Ada exception block does NOT work?



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.

> 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.)

> 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.

> 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.

.



Relevant Pages

  • Re: Ada exception block does NOT work?
    ... > parent language in not checking certain core operations. ... generally exceptions ... > But as we know from SPARK, use of Ada in such environments ... >> have propagated out of the scope of their definitions. ...
    (comp.lang.ada)
  • Re: Teaching new tricks to an old dog (C++ -->Ada)
    ... > templates and exceptions. ... Does it mean these languages are closer than ... Yes, these languages (C++ and Ada) are quite similar in many ways, and ...
    (comp.lang.cpp)
  • Re: Teaching new tricks to an old dog (C++ -->Ada)
    ... > templates and exceptions. ... Does it mean these languages are closer than ... Yes, these languages (C++ and Ada) are quite similar in many ways, and ...
    (comp.lang.ada)
  • Re: Tutorial and guidelines: Coding standards (long message)
    ... >> Many languages already have well established coding standards. ... Since I have referenced an Ada style guide I will speak of the ... Ada way to make scope visible. ... An Ada package is added to the scope of a program ...
    (comp.programming)
  • Re: Tutorial and guidelines: Coding standards (long message)
    ... >> Many languages already have well established coding standards. ... Since I have referenced an Ada style guide I will speak of the ... Ada way to make scope visible. ... An Ada package is added to the scope of a program ...
    (comp.os.linux.development.apps)