Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site ucbvax.BERKELEY.EDU Path: utzoo!watmath!clyde!burl!ulysses!ucbvax!info-modula-2 From: manis@UBC.CSNET (Vincent Manis) Newsgroups: net.lang.mod2 Subject: Exceptions Message-ID: <913:manis@cs.ubc.cdn> Date: Mon, 3-Feb-86 17:26:24 EST Article-I.D.: cs.913:manis Posted: Mon Feb 3 17:26:24 1986 Date-Received: Wed, 5-Feb-86 05:06:08 EST Sender: daemon@ucbvax.BERKELEY.EDU Organization: The ARPA Internet Lines: 28 I'm personally strongly opposed to hardwiring exception handling into programming languages. In part, this is because one wants to discourage routine use of exceptions for other than error handling; in part, because one of the major virtues of Modula-2 is its small size. Exceptions, by their very nature, are global. One signals an exception, and any module in the system (or at least in the dynamic execution history of the program) can catch them. As a result, two modules may have different ideas on what to do with a given exception. Thus, there are very good program structuring arguments against extensive use of exceptions. What many people have missed is that Modula-2 gives the programmer ''local exceptions'', in the form of procedure variables. Rather than exporting an exception, a module may export a procedure variable (or a procedure which accepts a procedure parameter). The client module can assign this variable a value; when an exceptional condition occurs, the procedure is invoked, and does whatever the client deems appropriate. It should be noted that this possibility is not present in Ada(TM), as procedure variables and procedural parameters are not provided (the Steelman specification explicitly ruled them out; I never understood why). There are, however, a number of situations in which exception handling (or more precisely non-local jumps) are necessary. Jeffrey McArthur's proposals are quite reasonable (though I'd prefer to represent exception names by integers rather than character strings, for efficiency's sake). The C setjmp/longjmp facility, which McArthur references, is quite good enough by itself, though, and very easy to implement.