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,ec4cde5d799065b6 X-Google-Attributes: gid103376,public From: eachus@spectre.mitre.org (Robert I. Eachus) Subject: Re: GOTO considered Satanic (was: Is there an ADA analogue to the C++ continue statement?) Date: 1997/10/07 Message-ID: #1/1 X-Deja-AN: 278517281 References: <3422F037.41CA@lmco.com> <3423AF1B.5152@i.b.m.net> <6098m7$a24$1@krusty.irvine.com> Organization: The Mitre Corp., Bedford, MA. Newsgroups: comp.lang.ada Date: 1997-10-07T00:00:00+00:00 List-Id: In article mheaney@ni.net (Matthew Heaney) writes: > Well, there are reasons for not using exceptions for normal control flow: > the famous RM 11.6 (though that section may - I think - only apply to > predefined exceptions; that section still throws me). If you need a goto, > then use a goto, not an exception. The wording in 11.6(5) in the new RM cleans up this problem almost completely. The only case where you can still find yourself fighting the optimizer is: declare Junk: Integer; begin Junk := X * Y; exception when Constraint_Error => Handle_Value_Too_Big; end; Since Junk is never referenced, the optimizer is allowed to leave the value of X * Y undefined, and in fact not compute it. To do this type of check correctly try: declare Junk: Integer; begin Junk := X * Y; if Junk > Integer'LAST then Ada.Text_IO.Put_Line("Foo!"); end if; exception when Constraint_Error => Handle_Value_Too_Big; end; The call to Put_Line can never be made, but it prohibits the optimizer from deciding that the value of Junk has no effect. -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...