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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ee1a8b8db84c88f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!proxad.net!134.158.69.22.MISMATCH!in2p3.fr!oleane.net!oleane!hunter.axlog.fr!nobody From: Jean-Pierre Rosen Newsgroups: comp.lang.ada Subject: Re: Ada exception block does NOT work? Date: Thu, 18 Aug 2005 16:42:41 +0200 Organization: Adalog Message-ID: <0p62ed.h3o.ln@hunter.axlog.fr> References: <4301ab29$0$6989$9b4e6d93@newsread2.arcor-online.net> <54s1ed.kjh.ln@hunter.axlog.fr> NNTP-Posting-Host: mailhost.axlog.fr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: s1.news.oleane.net 1124377275 12561 195.25.228.57 (18 Aug 2005 15:01:15 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Thu, 18 Aug 2005 15:01:15 +0000 (UTC) User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: fr, en In-Reply-To: Xref: g2news1.google.com comp.lang.ada:4163 Date: 2005-08-18T16:42:41+02:00 List-Id: Maciej Sobczak a �crit : > Jean-Pierre Rosen wrote: > >> There are no predefined exceptions in C++ > > > There are. 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. >> 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. 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. >> 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? 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: >> 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@adalog.fr) Visit Adalog's web site at http://www.adalog.fr