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
Date: 1997-10-07T00:00:00+00:00 [thread overview]
Message-ID: <EACHUS.97Oct7162405@spectre.mitre.org> (raw)
In-Reply-To: mheaney-ya023680002609970839420001@news.ni.net
In article <mheaney-ya023680002609970839420001@news.ni.net> 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...
next prev parent reply other threads:[~1997-10-07 0:00 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-09-17 0:00 Is there an ADA analogue to the C++ continue statement? Heath, Terry D.
1997-09-18 0:00 ` Pascal Obry
1997-09-18 0:00 ` Samuel Tardieu
1997-09-18 0:00 ` Robert A Duff
1997-09-19 0:00 ` Robert Dewar
[not found] ` <3422F037.41CA@lmco.com>
1997-09-20 0:00 ` dan13
1997-09-21 0:00 ` Robert Dewar
[not found] ` <3426B51E.7296@lmco.com>
1997-09-22 0:00 ` Coding Standards & GOTO Matthew Heaney
1997-09-23 0:00 ` Mark A Biggar
1997-09-24 0:00 ` Shmuel (Seymour J.) Metz
1997-09-24 0:00 ` W. Wesley Groleau x4923
1997-09-24 0:00 ` Aaron Quantz
1997-09-26 0:00 ` Charles H. Sampson
1997-09-23 0:00 ` Coding Standards W. Wesley Groleau x4923
1997-09-23 0:00 ` Coding Standards & GOTO Charles Rose
1997-09-24 0:00 ` Matthew Heaney
1997-09-25 0:00 ` Shmuel (Seymour J.) Metz
1997-09-22 0:00 ` Is there an ADA analogue to the C++ continue statement? Richard D Riehle
1997-09-23 0:00 ` GOTO considered Satanic (was: Is there an ADA analogue to the C++ continue statement?) Adam Beneschan
1997-09-24 0:00 ` W. Wesley Groleau x4923
1997-09-24 0:00 ` Brian Rogoff
1997-09-25 0:00 ` Larry Kilgallen
1997-09-26 0:00 ` Matthew Heaney
1997-09-26 0:00 ` Brian Rogoff
1997-10-07 0:00 ` Robert I. Eachus [this message]
1997-09-25 0:00 ` Alan Brain
1997-09-25 0:00 ` Shmuel (Seymour J.) Metz
1997-09-22 0:00 ` Is there an ADA analogue to the C++ continue statement? Richard A. O'Keefe
1997-09-29 0:00 ` John G. Volan
1997-09-18 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox