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!apollo.UUCP!wyant From: wyant@apollo.UUCP (Geoffrey Wyant) Newsgroups: net.lang.mod2 Subject: exceptions (really volatile variables) Message-ID: <8604240042.AA13982@uw-beaver.arpa> Date: Tue, 22-Apr-86 09:00:16 EST Article-I.D.: uw-beave.8604240042.AA13982 Posted: Tue Apr 22 09:00:16 1986 Date-Received: Sat, 26-Apr-86 04:26:11 EST Sender: usenet@ucbvax.BERKELEY.EDU Organization: The ARPA Internet Lines: 59 One problem I see with implementing exceptions outside the language comes in the following form: VAR fileOpened: BOOLEAN ; Exceptions.SetHandler(status) ; IF status <> ok THEN IF fileOpened THEN FileSystem.Close(...); END ; END ; fileOpened := FALSE ; FileSystem.Open(...) ; fileOpened := TRUE ; Now a smart optimizing complier will notice that the first assignment to fileOpened is never used. It then thinks that it is free to delete that expression. This is clearly wrong. The fact is that either the compiler has to know about stack unwinders (exception handling) or there must be some way to declare that a variable is "volitale" and the compiler not optimize assignments to it. Similiar things can happen when dealing with IO devices (don't want optimize away those control register assignments !) Now I think that it's a bad idea to stick exception handling into the language, but the ability to specify attributes in a declaration, such as "volatile" seems to me to be usefull. Then one could write the above example as VAR fileOpened: [VOLITALE] BOOLEAN ; .... I think that the notion of attributes could be generalized to allow specifying field sizes for dealing with device registers: VAR mythicalCSR: [VOLITALE] RECORD [BITS] commands: SET OF (go, halt, catchFire) ; [BITS] status: SET OF (broken, flaming, toasting, running) ; END (* record *); What do other people think of this ? I think it provides usefull functionality without warping the language too much. Geoff Wyant -------