Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!bu.edu!inmet!stt From: stt@inmet.inmet.com Newsgroups: comp.lang.modula3 Subject: Re: Local exceptions Message-ID: <370700001@inmet> Date: 29 May 91 15:18:00 GMT Lines: 41 Nf-ID: #R:<9105180946.AA24240@jumbo.pa.dec:-37:inmet:370700001:000:1531 Nf-From: inmet.inmet.com!stt May 29 11:18:00 1991 Re: non-top-level exceptions > /* Written 12:41 pm May 21, 1991 by stolfi@src.dec.com */ > > [Greg Nelson:] The question is, what do you want to be the result > of P(TRUE) after: > > PROCEDURE P(b: BOOLEAN) RAISES ANY = > EXCEPTION E; > BEGIN > IF b THEN > TRY P(NOT b) EXCEPT E: (* Skip *) END > ELSE > RAISE E > END > END P; > > I suppose the most useful interpretation is that each *static* > occurrence of "EXCEPTION Id" defines a new exception, irrespective > of how many times it is "executed". Then all occurrences of E in the > above example refer to the same exception. > > Admittedly this is not consistent with the principle of structural > type equivalence, but is at least consistent with the semantics of > BRANDED T. Ada took this path to defining the meaning of exceptions declared in a recursive procedure, namely that each "static" occurrence defines a unique exception. My recommendation: Avoid the problem. Stick with top-level only. It is of marginal use to allow local exceptions, and the butchery done to the normal model of declarations is not worth the trouble. Furthermore, it really gets nasty with "generics" in Ada, since each instantiation is considered a new "static" occurrence, requiring replication of exceptions even if otherwise the code can be shared between two generic instantiations. S. Tucker Taft stt@inmet.inmet.com Intermetics, Inc. Cambridge, MA 02138