From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.0 required=3.0 tests=BAYES_20 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 4 Nov 92 03:11:33 GMT From: portal!cup.portal.com!R_Tim_Coslet@uunet.uu.net Subject: Re: help with Ada question Message-ID: <68832@cup.portal.com> List-Id: In article: <1992Nov1.090527.29814@beaver.cs.washington.edu> pschwrtz@lynx.cs.washington.edu (Paul Schwartz) wrote: >robert walker (rwalker@barnacle.micro.umn.edu) wrote: >: >: If neither an exit nor a goto statement were available for Ada, how >: might you simulate the action of an exit statement? >: > The easiest way would be to put the loop in a block and use an >EXCEPTION to get out of the loop. As in; >fooLoop: >BEGIN > LOOP > IF THEN > RAISE Some_Error; > END IF; > > stuff > END LOOP; > EXCEPTION > WHEN Some_Error => NULL; --you just wanted out of the loop >END fooLoop; > It may be EASY, but don't EVER use exceptions as a "normal" means of exiting a loop!!!! The overhead of an exception may be significant and this is a misuse of the feature!!! This is fine, IFF the exit from the loop was because of an error condition that would normally never occur. Of course this is purely a "class assignment" question, as any real programming rules would never prohibit use of exit statements! R. Tim Coslet Usenet: R_Tim_Coslet@cup.portal.com technology, n. domesticated natural phenomena