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,335027991b3a97ec X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Debug code Date: 1996/03/18 Message-ID: #1/1 X-Deja-AN: 143128603 references: <1996Mar14.223326.13730@nosc.mil> <4iborm$a27@dfw.dfw.net> organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-03-18T00:00:00+00:00 List-Id: In article , Robert Dewar wrote: >... Actually thre are good reasons why >this is not in the standard. I disagree. >... It is surprisingly quite difficult to define >exactly from a semantic point of view (the issue is that if it really is >equivalent to the if from a formal semantic point of view, then the >compiler could draw conclusions from its existence and affect code >outside the Assert which you don't want. I disagree. I think this is exactly what you *do* want. In this regard, I see no difference between "pragma Assert(X <= 10);" and a normal range check, as for "X: Integer range 1..100;". IMHO, the pragma should be *exactly* semantically equivalent to an if_statement. (It's not syntactically equivalent, because you can't put an if_statement in a package spec.) If you turn the pragma off, it should be *exactly* semantically equivalent to a null_statement. (I realize that Asserts can contain side effects, but that unfortunate fact does not change my mind on this point.) >you need a null statement: > > else > pragma Assert ( ...); null; > end if; Yuck. I regularly have to compile my code twice after inserting an Assert, because of this Ada silliness. >Incidentally the GNAT source is full of pragma Assert statements, which is >why the current front end is very slow compared to what it will be in a >future release. Have you measured this? Even if you're not ready to turn them off, it would be interesting to try it just once, to see how much speed could be gained by turning them off. - Bob