From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bc243f3bb85ffa4f X-Google-Attributes: gid103376,public From: gauthier@unilim.fr (Michel Gauthier) Subject: Re: Exceptions: Are they GOTOs? Date: 1996/07/11 Message-ID: #1/1 X-Deja-AN: 167760201 references: organization: Universite de Limoges newsgroups: comp.lang.ada Date: 1996-07-11T00:00:00+00:00 List-Id: In article , brad@cs.uwa.oz.au (Bradley Edelman) wrote: >> What do people think about exception handling? I believe it to be a major >> strength of Ada but there is a school of thought that exceptions are just >> GOTO statements and should be avoided accordingly. >> >> I think raising an exception is a neater way of handling an error than, say, >> returning an error code or status. >> >> I'd appreciate thoughts either way. You might find a somewhat long answer in my book "Ada, a professional course", published by Macmillan. May I abstract it here ? The main difference between exception raise and goto is that : - raising an exception is essentially declarative : I assert that... - goto'ing (rather than 'going to') is imperative : do this... Exceptions are not a concept. The concept is 'reporting' that the required service could not be obtained. Exceptions can implement reports, as well as any kind of status code. Most of the problems come from reporting, not from its implementation. The main problem is not in goto nor in raise but in the lable or in the handling. It is caused by the multipleness of program flows that converge. Hence : - the assertion is a disjunct, therefore weakened, - generally, the programmer has only a partial knowledge of this set of arrows, and in fact knows nothing useful. Additional thougths later, if requested. ---------- ---------- ---------- ---------- Michel Gauthier / Laboratoire d'informatique 123 avenue Albert Thomas / F-87060 Limoges telephone +33 () 55457335 [or ~ 7232] fax +33 () 55457315 [or ~7201] ---------- ---------- ---------- ---------- La grande equation de la fin du siecle : windows-X = Mac-Y The main end-of-century equation : windows-X = Mac-Y ---------- ---------- ---------- ---------- Si l'an 2000 est pour vous un mysticisme stupide, utilisez la base 9 If you feel year 2000 a stupid mystic craze, use numeration base 9 ---------- ---------- ---------- ----------