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=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!bu.edu!encore!jcallen From: jcallen@Encore.COM (Jerry Callen) Newsgroups: comp.lang.ada Subject: Re: Exceptions Message-ID: <14239@encore.Encore.COM> Date: 6 Mar 91 21:21:21 GMT References: <9103061724.AA02582@libra.cs.nps.navy.mil> Reply-To: jcallen@encore.Com (Jerry Callen) Organization: Encore Computer Corp, Marlboro, MA List-Id: In article <9103061724.AA02582@libra.cs.nps.navy.mil> erickson@taurus.cs.nps.navy.mil (David Erickson) writes: >Can I assume that any block with an exception handler will require an >activation record at run-time (as will blocks with declarations, procedures, >functions and packages)? No, you can't assume that; it depends upon the implementation. Every compiler I've worked with imposed no runtime overhead for entering and leaving the scope of an exception handler. This is done by having tables (organized in various ways, depending upon the implementation) that relate a range of addresses with exception handlers. The pc is used to search the tables. >Exception handling appears to be inherently inefficient, since the entire >dynamic chain may have to be searched, checking each activation for an >appropriate handler (including activations which have no handler). It's possible to do this checking very quickly and combine it with unwinding the stack. But, yes, you do have to pay for exception handling when an exception occurs. >Since exception declarations obey static scoping rules, but the search >for exception handlers follows dynamic links, an exception can go out of >and back into scope (see Barnes pg. 181 for an example). How are names >resolved in such a way that two exceptions with the same name, declared >in different parts of the program, do not get confused? The "thing" that represents an exception is (in all the compilers I've used) not the exception name itself, but rather the _address_ of a string containing the name. Identical names are represented by multiple copies of the name string; since the addresses are different, there is no confusion. >-Dave Erickson -- Jerry Callen jcallen@encore.com