From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ee1a8b8db84c88f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!g44g2000cwa.googlegroups.com!not-for-mail From: "Hyman Rosen" Newsgroups: comp.lang.ada Subject: Re: Ada exception block does NOT work? Date: 18 Aug 2005 09:38:50 -0700 Organization: http://groups.google.com Message-ID: <1124383129.977718.320820@g44g2000cwa.googlegroups.com> References: <4301ab29$0$6989$9b4e6d93@newsread2.arcor-online.net> <%s2Ne.2$5F1.1@dfw-service2.ext.ray.com> NNTP-Posting-Host: 204.253.248.208 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1124383135 16322 127.0.0.1 (18 Aug 2005 16:38:55 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 18 Aug 2005 16:38:55 +0000 (UTC) User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: g44g2000cwa.googlegroups.com; posting-host=204.253.248.208; posting-account=lJDDWg0AAACmMd7wLM4osx8JUCDw_C_j Xref: g2news1.google.com comp.lang.ada:4167 Date: 2005-08-18T09:38:50-07:00 List-Id: 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.