Newsgroups: comp.object,comp.lang.eiffel,comp.lang.c++,comp.lang.beta,comp.lang.java,comp.lang.sather Path: news.daimi.aau.dk!news.uni-c.dk!newsfeed.sunet.se!news01.sunet.se!sunic!news99.sunet.se!erinews.ericsson.se!cnn.exu.ericsson.se!newshost.convex.com!news.duke.edu!news.mathworks.com!newsfeed.internetmci.com!howland.reston.ans.net!math.ohio-state.edu!newsfeed.acns.nwu.edu!ftpbox!mothost!schbbs!news From: shang@corp.mot.com (David L. Shang) Subject: Re: What Should An Exception Handling Do? -- Clarification of rules Reply-To: shang@corp.mot.com Organization: MOTOROLA Date: Tue, 2 Apr 1996 15:47:22 GMT Message-ID: <1996Apr2.154722.29777@schbbs.mot.com> References: Sender: news@schbbs.mot.com (SCHBBS News Account) Nntp-Posting-Host: 129.188.128.126 Lines: 50 Xref: news.daimi.aau.dk comp.object:53647 comp.lang.eiffel:22638 comp.lang.c++:176413 comp.lang.beta:10703 comp.lang.java:30916 comp.lang.sather:12394 In article pcg@aber.ac.uk (Piercarlo Grandi) writes: > Therefore exception handling reduces to simply providing a mechanism by > which the *author* of a code segment provides a mechanism by which the > *user* of that code segment can specify additional cases, as for example > in: > > float sqrt(float n) > { > if > n > 0 -> ...; > [] n == 0 -> return 0; > [] n < 0 -> return sqrt_negative(n); > fi > } > > where the only difficulty is that sqrt_negative must be dynamically > scoped instead of statically scoped, for it must be redefinable by the > *user* of the procedure. > > This again means that termination is the only possible outcome for this > case too. > Termination? When you execute: return sqrt_negative(n) first, you call "sqrt_negative" to get the result, then you do return to terminate. It is not the case that you first terminate then you call "sqrt_negative". Once your terminate, you can never go back. If I write code like: float sqrt(float n) { if n > 0 -> ...; [] n == 0 -> return 0; [] n < 0 -> { n1= sqrt_negative(n); return n1; } fi } Is the program terminated at the point of calling "sqrt_negative"? This embedded exception handler exactly provides a resumption semantics, which, according to your previous analysis, is the only case that exception handling makes any sense(?). David Shang