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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1096a7986b560ad6 X-Google-Attributes: gid103376,public From: nabbasi@earthlink.net Subject: Re: In Exception ? Date: 1998/04/09 Message-ID: <6gkbdt$rmu@drn.newsguy.com>#1/1 X-Deja-AN: 342661540 References: <35214b7a.0@news.profinet.at> <6g7fpc$l08$1@usenet.rational.com> <6gcjru$7im@drn.newsguy.com> <352D0352.A5C6D4BA@elca-matrix.ch> Organization: Newsguy News Service [http://www.newsguy.com] Newsgroups: comp.lang.ada Date: 1998-04-09T00:00:00+00:00 List-Id: In article <352D0352.A5C6D4BA@elca-matrix.ch>, Mats says... > >nabbasi@earthlink.net.NOSPAM wrote: > >> I think Ada should have a function that tells one if they are in an >> exception handler or not. I know this is platform specific stuff, but >> that is the whole idea of using Ada, to hide platform specific things >> from the user. I remember that PLIon VMS had such a call in its run-time >> library, I could be wrong though. > >Would that function return True or False at --B in the code below ? And if it >is called from a subprogram that is called form --A ? I think the concept of >"being in an exception handler" is just not so easy to define well. > >begin > ... --A >exception > when e => > begin > ... --B > exception > when f => > ... > end; >end; well, I was thinking in general terms, of an exception handler as a "procedure" that is called by the system when an exception occurs. May be if one stays within Ada, it might not be clear. but from a system point of view, it is very clear. When a procedure "establishes" a condition handler, an address of a function that is the handler is stored somewhere, in VMS land, each procedure frame contains an entry that contains the address of an expection handler established in that procedure. If the slot in the frame is zero, then there is no excpetion handler established for THAT procedure, and when an exception happens in that procedure (divid by zero, access violation etc..) the system will rewide the stack to the next frame, and will then look to see if there is an exception handler establised in that frame, and so on. So, to ask if one is in exception handler or not, the system will have to look at the stack and to trace to see if the caller of this procedure is an exception handler for some other procedure, (it will know if the address of the procedure is stored in the exception handler address slot in the call frame of the procedure that established it) . for some other system , depending on how exception handlers are designed, this might or might not be possible. I understand that in Ada, an exception handler is a block of code within a procedure, someone said that going to that block is like doing a goto, i.e. it is not a separate procedure. And so based on this, what I was thinking of might not apply to Ada. Nasser