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,deeb88b0e7eede4f X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Help with Exceptions! Date: 1996/05/10 Message-ID: #1/1 X-Deja-AN: 154182045 references: <4mmimq$s4r@hatathli.csulb.edu> <4mqio5$a8b@news.sanders.lockheed.com> <4mt0um$dgu@hearst.cac.psu.edu> organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-05-10T00:00:00+00:00 List-Id: In article , Jon S Anthony wrote: >This is a nice trick which allows you to approximate Eiffel style >exception capabilities. I don't like Eiffel's exception capabilities. The "retry" feature is just a loop implemented with a goto (i.e. "retry" is really a backward goto). I much prefer the Ada style, where you explicitly code a loop statement, and put a block-statement-with-exception-handler inside that. Eiffel has some nice features for asserting things about loops (loop invariants, and loop variants -- the latter helps prove that the loop terminates in a finite number of steps). But the retry construct seems to by-pass all that -- how does one prove that a retry will ever terminate? Of course, the example below is *intentionally* an infinite loop, which is fine. If the user never types the right answer, it loops forever (or recurs forever, until stack is exhausted, unless the compiler is clever enough to turn the tail recursion into a jump). (Is it "recurs" or "recurses"?. ;-) ) Whether or not this is user-friendly is a different question. >> function Response (Prompt : String) return integer is >> >> line : ... >> Size : ... >> >> begin >> Put (Prompt); >> Get_Line (...; >> return ... >> exception >> when others => >> Put_Line (...; -- error message >> return Response(Prompt); >> end Response; - Bob