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,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a571dbe59eac7150 X-Google-Attributes: gid103376,public From: "Corey Ashford" Subject: Re: new language construct proposed Date: 1998/02/14 Message-ID: <6c5k86$r9k$1@usenet.rational.com>#1/1 X-Deja-AN: 325445378 References: <6avo1d$sul@lotho.delphi.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4 Organization: Rational Software Newsgroups: comp.lang.ada Date: 1998-02-14T00:00:00+00:00 List-Id: Robert Dewar wrote in message ... >tmoran said > >< if boolean_expression then raise exception_name;end if; >>> > >Well of course, as we all understand, it is *not* different at all. We >are talking minor convenience here, nothing more. But note that the >above argument would equally well argue against the inclusion of > > exit loopname when <> > >in the language. > >I think the reason that we justify it for exit, and not for raise >(and most CERTAINLY not for all simple statements, nasty thought ...) >is that exit is rather special since it is essentially part of the >structure of a loop. > If you don't like the "if" statement, a procedure call would work too, but it's not terribly pretty: procedure Raise_When(Condition : Boolean; Exception_Id: Ada.Exceptions.Exception_Id; Message : String := "") is begin if Condition then Ada.Exceptions.Raise_Exception(Exception_Id, Message); end if; end Raise_When; pragma inline(Raise_When); An example usage: Raise_When(a > 17 and b = 0, Constraint_Error'identity, "Ephemeris Error"); This way you can add a string to the exception if desired. Also, you could null out the body of this routine when you're getting ready to ship, to improve performance. Since it's inline, it doesn't cost you much.