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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1a4156f047b063f X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsfeed01.chello.at!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Forcing Exception Handling Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <02901b13-da72-48ae-9cb3-bf1a10144c44@u3g2000vbe.googlegroups.com> <4d6c07c1$0$6885$9b4e6d93@newsspool2.arcor-online.net> <195bsgigtzacu$.13u18z09ptrtw$.dlg@40tude.net> Date: Tue, 1 Mar 2011 16:44:01 +0100 Message-ID: NNTP-Posting-Date: 01 Mar 2011 16:44:01 CET NNTP-Posting-Host: 24b980d1.newsspool4.arcor-online.net X-Trace: DXC=f64d;e_mX6J2jYf>V4L0gL4IUK On Tue, 1 Mar 2011 07:23:56 -0800 (PST), Shark8 wrote: > On Mar 1, 1:56�am, "Dmitry A. Kazakov" > wrote: >> >> Also consider this: >> >> � �declare >> � � � Foo : exception: >> � �begin >> � � � ... >> � � � raise Foo; >> � �end; �-- Foo propagates out its scope!! >> > > What's wrong with handling it with OTHERS? You have an object of non-existent type: when Error : others => Assuming that Error is of Root_Exception_Type'Class, what should Error'Tag return? >> A possibility to handle this is exception promotion, e.g. Foo to >> Program_Error, when Foo gets finalized. > > A third is to convert Exceptions to a hierarchy as stated in my last > post. No, that does not work, because the exception type would be dead in the handler. C++ model cannot work in Ada 2005+, because in Ada tagged types can be local. Further problems are overlapping choices in the exception clause. If the semantics of exception when X => when Y => is dispatching on the tag of the current exception, which people suggesting class-wide exceptions have in mind. Then that would be incompatible with the choice when others => which has the semantics of a class-wide call. If you choose that semantics instead, then you would have to write exception when X'Class => when Y'Class => and lose the property that alternatives do not overlap. That is way unacceptable to me. These are the reasons why I don't think that exception -> type mapping is such a good idea. I prefer exception -> value mapping + contracts. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de