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,7d3cb5920e882220 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Exceptions Date: Tue, 11 Dec 2007 18:01:43 -0600 Organization: Jacob's private Usenet server Message-ID: References: <5947aa62-2547-4fbb-bc46-1111b4a0dcc9@x69g2000hsx.googlegroups.com> <475c6ed8$0$13111$9b4e6d93@newsspool2.arcor-online.net> <1kxk3hlfa25dw$.fl2wvbn0tpbg$.dlg@40tude.net> <475d296a$0$27813$4f793bc4@news.tdc.fi> <12mjar2f2t2e6$.o2upq0n29j1f.dlg@40tude.net> <475d99c6$0$3520$4f793bc4@news.tdc.fi> <1x0h6yxp9rhy1.1thonmo9cmwy3$.dlg@40tude.net> <475e8bde$0$27850$4f793bc4@news.tdc.fi> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1197417542 12451 69.95.181.76 (11 Dec 2007 23:59:02 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 11 Dec 2007 23:59:02 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1914 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1914 Xref: g2news1.google.com comp.lang.ada:18905 Date: 2007-12-11T18:01:43-06:00 List-Id: "Niklas Holsti" wrote in message news:475e8bde$0$27850$4f793bc4@news.tdc.fi... ... > And perhaps also > > 5. Exceptions as formal generic parameters. Ada has this (although it isn't obvious): just pass an Ada.Exceptions.Exception_Id to the generic. That is, given a generic spec something like: generic My_Exception : Ada.Exceptions.Exception_Id := Constraint_Error'Identity; package Gen is ... you can instantiate it with any exception you like: package Inst is new Gen (Program_Error'Identity); and you can raise the exception inside the generic: Ada.Exceptions.Raise_Exception (My_Exception, Message => "Wow!"); and you can even handle the exception with a little cleverness: when Occ:others => if Ada.Exceptions.Exception_Identity (Occ) = My_Exception then -- Handle My_Exception. else raise; -- Not the one we want. end if; (This last is how Janus/Ada has to implement handlers for exceptions declared inside of generics anyway, so in our case at least, the code cost is essentially the same.) All but the last as just as good as a "real" exception formal, and the last doesn't happen that much in reusable stuff (usually such things are originating or propagating exceptions, not handling them). In any case, the fact that it is relatively easy to do this is why there is no formal exception parameter. Randy.