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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3b4bed4f74b8ac49 X-Google-Attributes: gid103376,public From: "Norman H. Cohen" Subject: Re: GNAT messages and the not operator (pitfall alert!) Date: 1996/10/29 Message-ID: <32762A30.D2D@watson.ibm.com>#1/1 X-Deja-AN: 193101177 references: content-type: text/plain; charset=us-ascii organization: IBM Thomas J. Watson Research Center mime-version: 1.0 reply-to: ncohen@watson.ibm.com newsgroups: comp.lang.ada x-mailer: Mozilla 3.0 (Win95; I) Date: 1996-10-29T00:00:00+00:00 List-Id: Robert Dewar wrote: > > Here is another pitfall, pretty horrible if it hits, but fortunately rare. > Ask an Ada expert what is the value of > > -5 mod 3 I agree this is a nasty one, and Ada as a Second Language explicitly warns about it (bottom of page 245), as well as about the only slightly less insidious A+B mod C (which means A + (B mod C)). However, the not A > B case is less troubling to me, because each relational operator and membership test has a complement, and a programmer is far more likely to write "A <= B" rather than "not A < B" if he means "not (A < B)". (Yes, I know ">" might be overloaded with some partial ordering so that A<=B and A>B are both false, but that is hardly the typical case!) Also, as Robert pointed out, this case (unlike the mod case) will usually manifest itself as a type mismatch. -- Norman H. Cohen mailto:ncohen@watson.ibm.com http://www.research.ibm.com/people/n/ncohen