Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!decwrl!pa.dec.com!src.dec.com!stolfi From: stolfi (Jorge Stolfi) Newsgroups: comp.lang.modula3 Subject: Re: Local exceptions Message-ID: <9105211642.AA01692@jumbo.pa.dec.com> Date: 21 May 91 16:41:56 GMT Lines: 57 To: gnelson Cc: m3 X-Folder-Carbon: lang-des [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. By the way, here is another situation where the Report seems a bit ambiguous about static versus dynamic scopes: MODULE M2 EXPORT Main; PROCEDURE MemeChose(n: INTEGER; p: PROCEDURE():INTEGER): BOOLEAN = PROCEDURE G(): INTEGER = BEGIN RETURN n END G; BEGIN IF n = 0 THEN RETURN p = G ELSE RETURN MemeChose(n-1, G) END END F; PROCEDURE Irrelevant(): INTEGER = BEGIN RETURN 0 END P0; BEGIN <* ASSERT NOT MemeChose(1, Irrelevant) *> END M2. Should the ASSERT fail or succeed? The question is whether all instances of G are the same procedural value, i.e. whether the "environment" component of a procedure value is a static scope or a dynamic scope. To further confound the issue, the Report calls G a procedure *constant*... (The SRC compiler does the right thing, by the way.) --jorge