Path: news.cs.au.dk!not-for-mail From: "Jørgen Lindskov Knudsen" Newsgroups: comp.lang.beta Subject: Re: Static vs. dynamic exceptions Date: Tue, 20 Jun 2000 12:09:45 +0200 Organization: University of Aarhus, Department of Computer Science (DAIMI) Lines: 88 Message-ID: <8infta$9jn7$1@xinwen.cs.au.dk> References: <20000619173848.8485.qmail@noatun.mjolner.dk> <8im02p$8s5j$1@xinwen.cs.au.dk> NNTP-Posting-Host: nott.mjolner.dk X-Trace: xinwen.cs.au.dk 961495786 315111 255.255.255.255 (20 Jun 2000 10:09:46 GMT) X-Complaints-To: news@cs.au.dk NNTP-Posting-Date: 20 Jun 2000 10:09:46 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Xref: news.cs.au.dk comp.lang.beta:12452 Peter von der Ahé wrote in message news:yc0hfaoptnv.fsf_-_@ufleku.cs.au.dk... > ... > It does seem to me that every modern language support some kind of > dynamic exceptions. It appears as if the reason for BETA only[1] > supporting static exceptions is that leave and restart are limited > (statically?/lexically?) in the Mjolner implementation. > > Are the limitations to leave and restart justified in the original > language definition, or were they chosen because they were the most > easily implemented? There is no connection between leave/restart and static exception handling - these two issues have been discussed and designed separately (look e.g. at [ref1] or the chapter in the BETA book). [ref 1] Knudsen, J.L.: Exception Handling - A Static Approach, Software - Practice & Experience, 14(5), 429-449, May 1984. > /Peter > > **** > > [1] Look at dynamic vs. static exceptions. It should be clear that > dynamic exceptions can simulate static exceptions: > > try > (# > catch::(# (* handle syntaxerror *) #) > do getint -> i > #) > > which simulates: > > getint(# syntaxError::(# (* handle error *) #) #) -> i > > You could even write (might not be correct, but you should get the > idea): > > -- streamlib: attributes -- > getIntStaticEx: > (# > syntaxError:< exception; > i: @integer > do > try > (# > catch:: > (# do (if e // syntaxerror then syntaxError if) #) > do getInt -> i > #) > exit i > #) > > I do not believe that it is possible to simulate dynamic exceptions > with static exceptions and if this is true one could say that dynamic > exceptions is a proper superset of static exceptions. Please prove me > wrong. This is a religious discussion :-) To give an example: it is possible to write object-oriented structures in say C (i.e. simulate OO in C). However, nobody would say C thereby supports OO. The simulation above is very error-prone, and leaves it entirely to the programmer to implement´the static redirection of the dynamic exception to the proper statix exception. This implies, that some programmers will get it wrong, and during maintenance, there is a huge risk, that the structure is not preserved (e.g. since the programmers taking over the responsabilities for the code does not fully understand the implications of the code. Thus, 'simulation' isn't sufficient - could you on the other hand implement an abstraction with the necessary semantics, etc., we would be in another ballgame. However, whether static and dynamic ex.handling is a choice between models, or both are needed is an open question right now - actually this very subject was discussed at the Workshop on Exception Handling at the ECOOP'2002 conference last week. Currently, my conception is that both mechanisms have their merit (for slightly different purposes), perhaps warrenting having both (actually a very preliminary design exists for BETA). Regards, Jørgen Lindskov Knudsen