Path: news.cs.au.dk!not-for-mail From: nospam2159@cs.au.dk (Peter von der =?iso-8859-1?q?Ah=E9?=) Newsgroups: comp.lang.beta Subject: Re: exceptions: (atle // confused (# again #) atle) Date: 19 Jun 2000 18:44:55 +0200 Organization: Computer Science Department of the University of Aarhus Lines: 65 Message-ID: References: <394E2F9C.F934A4BF@skynet.be> NNTP-Posting-Host: ufleku.cs.au.dk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: xinwen.cs.au.dk 961433095 287965 255.255.255.255 (19 Jun 2000 16:44:55 GMT) X-Complaints-To: news@cs.au.dk NNTP-Posting-Date: 19 Jun 2000 16:44:55 GMT X-Attribution: Ahe User-Agent: Gnus/5.0806 (Gnus v5.8.6) Emacs/20.6 Xref: news.cs.au.dk comp.lang.beta:12434 Atle, this might not help you, but anyways... Let my elaborate a bit on the topic of exceptions. I think that the exception mechanism in BETA is very inflexible and inconvenient. One of the very strong features of exceptions is that it allows you to write programs as they should have looked if no errors occurs, consider: "file.txt" -> file.open; (* open file for reading *) (* an error can occur here, eg. file.txt does not exist *) file.getInt -> i; (* read an integer *) (* an error can occur here, eg. the first word in the file is not an * integer *) In most modern language you have a try/catch mechanism (in BETA pseudo code): try(# catch:: (# (* handle errors *) #) do file.txt" -> file.open; file.getInt -> i; #) But in BETA you have to say something like: "file.txt" -> file.open (# noSuchFileError::(# (* handle error *) #) #); file.getInt (# syntaxError::(# (* handle error *) #) #) -> i; Consider this: file.getInt -> i; file.getInt -> j; file.getInt -> k; You can either make a specialised version of file or handle exceptions at each line explictly. Well of cause, you would select to make a specialised version - that's the most convenient and resembles the try/catch mechanism. But then consider the task of implementing a parser. Assume that this parser should be able to handle all kinds of streams, both text and file and others not even invented yet. Then you realize that BETA exception isn't very convenient. This leads me to my point: BETA does not have exceptions. I think the most needed language feature in BETA is exceptions. Alternatively closures could be implemented properly, that is allow: p: (# closure:@(# do leave p #) exit closure[] #) c:^object; do p -> c; c; This could be used to implement proper exceptions in BETA. -- YMMV