comp.lang.ada
 help / color / mirror / Atom feed
From: "Stanley R. Allen" <Stanley_R_Allen@raytheon.com>
Subject: Re: Ada exception limitations
Date: 2000/02/25
Date: 2000-02-25T00:00:00+00:00	[thread overview]
Message-ID: <38B71C41.3D37D653@raytheon.com> (raw)
In-Reply-To: 89738j$f27$1@nnrp1.deja.com

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




  reply	other threads:[~2000-02-25  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-25  0:00 Ada exception limitations jehamby
2000-02-25  0:00 ` Stanley R. Allen [this message]
2000-02-26  0:00 ` James S. Rogers
2000-02-26  0:00 ` Laurent Guerby
2000-02-27  0:00   ` jehamby
2000-02-26  0:00 ` Ehud Lamm
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox