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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1e4bb63e08046e1a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-26 16:04:54 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!news.tufts.edu!uunet!dca.uu.net!ash.uu.net!world!news From: Robert A Duff Subject: Re: is exception when others => null; smart? User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Sender: news@world.std.com (Mr Usenet Himself) Message-ID: Date: Sat, 26 Oct 2002 23:04:09 GMT Content-Type: text/plain; charset=us-ascii References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Organization: The World Public Access UNIX, Brookline, MA Xref: archiver1.google.com comp.lang.ada:30162 Date: 2002-10-26T23:04:09+00:00 List-Id: Dale Stanbrough 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