comp.lang.ada
 help / color / mirror / Atom feed
From: agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!math.ohio-state.edu!d arwin.sura.net!seas.gwu.edu!mfeldman@ucbvax.Berkeley.EDU  (Michael Feldman)
Subject: Re: Comparison of Ada and C++ exceptions?
Date: 19 Sep 93 21:39:39 GMT	[thread overview]
Message-ID: <1993Sep19.213939.4015@seas.gwu.edu> (raw)

In article <2790je$4en@nic.lth.se> dag@control.lth.se (Dag Bruck) writes:
>In <comp.lang.ada> Dale Stanbrough <dale@goanna.cs.rmit.edu.au> writes:
>>Recently I had reason to look at C++'s exception handling. I noticed that
>>each
>>exception can have associated with it some data (user defined), such as a
>>string, a pointer - in fact any object the programmer wants. 
>
>The C++ exception is an object, and I have often wanted to pass along
>some information that describes the problem.  Cf. the UNIX "exception"
>type that is used for problems detected in math routines.
>
>The exception-is-an-object idea also has the benefit that you can
>group exceptions by inheritance.  If you have
>
>	class MATHERROR ....
>	class OVERFLOW : public MATHERROR ....
>	class ZERODIVIDE : public MATHERROR ....
>	class DOMAINERROR : public MATHERROR ....
>
>You can either decide to catch overflows separately, or any math
>error, or a combination thereof:
>
>	catch (OVERFLOW) ....
>	catch (MATHERROR) ....	-- other math errors
>
>This is quite nice.

I agree. One of these days I will study C++ propagation/handling semantics
and see how it compares to Ada. But treating exceptions as real objects
is a good idea.

Mike Feldman

             reply	other threads:[~1993-09-19 21:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-09-19 21:39 agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!math.ohio-state.edu!d [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-09-16 14:28 Comparison of Ada and C++ exceptions? David Emery
1993-09-16  8:45 pipex!zaphod.crihan.fr!vishnu.jussieu.fr!univ-lyon1.fr!scsing.switch.ch!e
1993-09-16  6:20 Dag Bruck
1993-09-15  1:03 munnari.oz.au!bruce.cs.monash.edu.au!monu6!aggedor.rmit.OZ.AU!root
replies disabled

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