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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8ed8f00df051b989 X-Google-Attributes: gid103376,public From: "Stanley R. Allen" Subject: Re: Ada exception limitations Date: 2000/02/25 Message-ID: <38B71C41.3D37D653@raytheon.com>#1/1 X-Deja-AN: 590083633 Content-Transfer-Encoding: 7bit References: <89738j$f27$1@nnrp1.deja.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: NASA, Kennedy Space Center Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-02-25T00:00:00+00:00 List-Id: jehamby@lightside.com wrote: > > #1: No hierarchical exceptions. AFAIK, I can't declare an Ada > exception as a child of another exception, and then catch both > exceptions with a single 'when' clause. I wouldn't want to collapse > all of my custom exceptions down to a single Ada exception, but neither > putting a long list of when clauses into every exception handler, nor > using 'when others' for everything, appeals to me. This is a nice feature to *use* in Java and C++, but if I'm not mistaken, it generally carries a heavy runtime burden. For a real-time language like Ada, the expense of throwing exceptions as objects, and especially catching and distinguishing among them in handlers was probably considered too great (a language designer in this group may chime in and tell you more; Java was not around during the definition of Ada 95, but C++ was and I'm sure they'll tell you that they looked at this issue carefully). > #2: No ability to associate user data with exceptions. I know it's > possible to raise an exception with an associated string message, and I > could use this to pass the error number as a string, but this seems > kludgy. One of the developers in my organization always creates an Image and Value function for every class package he writes. Respectively, these create a string which represents the value of the (private) type, and a value from the string representation created by Image. He generally uses these for debugging, but the idea could be applied to make an 'exception object' in Ada 95. You could use the package Ada.Tags to generate a string 'type' distinguisher as the prefix of the string created by the Image function of the private type. Like you said, it's a bit of a kludge to convert between strings and values but it can allow some of the expressiveness of the C++/Java model. -- Stanley Allen mailto:Stanley_R_Allen@raytheon.com