comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: is exception when others => null; smart?
Date: Sat, 26 Oct 2002 23:04:09 GMT
Date: 2002-10-26T23:04:09+00:00	[thread overview]
Message-ID: <wcc8z0k245y.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: dstanbro-768960.06411826102002@mec2.bigpond.net.au

Dale Stanbrough <dstanbro@bigpond.net.au> writes:

> Robert A Duff wrote:
> 
> > Finalization can also be used for this purpose, and that's a cleaner way
> > to do it, but finalization is *very* expensive in most Ada compilers,
> > whereas the above "when others" is pretty cheap.
> 
> Are the same costs associated with C++ destructors, or is there
> something peculiar to Ada that causes it to be so expensive?

I don't know the details of C++ well enough to answer that
for sure.

It's interesting that C++ had destructors first, and then added
exception handling, and folks would rend their clothing over the added
complexity of exception handling.

Ada had exception handling first, and then added finalization, and folks
would rend their clothing over the added complexity of finalization.

The truth is that there are interactions between the two features,
and the last one added to the language gets the blame.

I suspect that the total complexity of these features in Ada and C++ is
roughly equal.  And likewise, the difficulty of doing it efficiently.
I think finalization *can* be done efficiently, but it's not easy.
I think the Rational compiler uses an efficient method, but the others
don't (including the one *my* company, SofCheck, sells -- sigh).

The one thing I can think of that is special to Ada is aborts (including
"select-then-abort" statements.  Finalization requires aborts to be
deferred, and that is expensive in many systems.  (I think the fact that
it's expensive is a design flaw in some operating systems, but since I
usually write compilers and not (desk-top) operating systems, I don't
have too much control over that.)  The "abort" issue does not come up
for C++.

- Bob



  reply	other threads:[~2002-10-26 23:04 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-24 14:03 is exception when others => null; smart? Preben Randhol
2002-10-24 14:25 ` David C. Hoos, Sr.
2002-10-24 14:28   ` Preben Randhol
2002-10-24 14:38 ` Per Sandbergs
2002-10-25 15:04   ` Robert A Duff
2002-10-25 20:41     ` Dale Stanbrough
2002-10-26 23:04       ` Robert A Duff [this message]
2002-10-26  7:47     ` tmoran
2002-10-24 16:39 ` Mark Biggar
2002-10-24 20:06   ` Robert A Duff
2002-10-24 20:23     ` Wes Groleau
2002-10-25  1:16       ` Jeffrey Carter
2002-10-25 10:10         ` In case statment? (was Re: is exception when others => null; smart?) Preben Randhol
2002-10-25 14:59           ` Robert A Duff
2002-10-25 15:06             ` Preben Randhol
2002-10-29 18:23             ` Peter Richtmyer
2002-10-30  2:52               ` Steven Deller
2002-10-30  8:58               ` Anders Wirzenius
2002-10-30 19:57                 ` Peter Richtmyer
2002-10-31  7:02                   ` Anders Wirzenius
2002-10-30  9:36               ` Lutz Donnerhacke
2002-10-30 19:44                 ` Peter Richtmyer
2002-10-30 13:28               ` Marin David Condic
2002-10-30 20:34                 ` Robert Spooner
2002-10-31 12:40                   ` In case statment? (was Re: is exception when others => null;smart?) Marin David Condic
2002-10-25 17:13           ` In case statment? <...> when others John Woodruff
2002-10-27 21:03           ` In case statment? (was Re: is exception when others => null; smart?) Ze Administrator
2002-10-28 10:04             ` Preben Randhol
2002-10-28 20:05               ` Wes Groleau
2002-10-30 11:31                 ` Preben Randhol
2002-10-28 12:32             ` In case statment? (was Re: is exception when others => null;smart?) Adrian Hoe
2002-10-24 20:11   ` is exception when others => null; smart? Simon Wright
2002-10-24 21:22     ` Larry Kilgallen
2002-10-24 20:03 ` Robert A Duff
2002-10-25  1:49 ` SteveD
2002-10-25  3:48 ` Dennis Lee Bieber
2002-10-26 11:34   ` Preben Randhol
replies disabled

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