Path: news.cs.au.dk!news.net.uni-c.dk!sunsite.auc.dk!newsfeed1.uni2.dk!skynet.be!poster!not-for-mail From: Atle Newsgroups: comp.lang.beta Subject: exceptions: (atle // confused (# again #) atle) Date: Mon, 19 Jun 2000 13:35:08 -0100 Organization: Belgacom Skynet SA/NV Lines: 37 Message-ID: <394E2F9C.F934A4BF@skynet.be> NNTP-Posting-Host: dialup310.charleroi.skynet.be Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news1.skynet.be 961414227 20944 194.78.236.182 (19 Jun 2000 11:30:27 GMT) X-Complaints-To: abuse@skynet.be NNTP-Posting-Date: 19 Jun 2000 11:30:27 GMT X-Mailer: Mozilla 4.51 [en] (X11; I; Linux 2.2.5-15 i686) X-Accept-Language: en Xref: news.cs.au.dk comp.lang.beta:12419 Eh ... Could someone please explain to me the difference between 'handling an exception' and 'checking the return value'. This may seem like a horrendous question, but C++ and Java has a ver strange program flow when doing exceptions. The C++/Java way resembles processor interrupts, whereas Beta - well it looks like the 'old' way? Here is the old way in pseudocode ( <> Not equals ) returnValue := openFile('SomeFile.bet') IF returnValue <> OK THEN produceError(returnValue); ELSE { do the normal processing. returnValue will be a legal file handle } ENDIF This is opposed to 'installing error handlers' and then 'trying'. Beta seems to be in the middle between two extremes. The key seems to lie in the returnValue semantics: I am used to seeing it as a 'value' (attribute), it will either be a legal file or some value like -1, 0 and then some global variable, like errno will indicate what went wrong. I guess all of you know Pascal, I am used to the IOResult way. I was alienated by this syntax: try { strm = bufferedstreamandsomestuffandtotallyunreadable(filename, OPENFLAGS); } catch(...) { cout << "The program has been somewhere and crashed" << " difficult to say if I should recover or what?"; } So, i know i will like the Beta way. But what way is it? Thanks, Atle (PS I have read the short description of 'static exceptions', so what I am looking for, is an explanation in terms of the 'old :-) way' and 'new :-( way'. And what is wrong with checking return values anyway? Tell me which of the above is easier to read and program, which one, huh? PS)