comp.lang.ada
 help / color / mirror / Atom feed
From: "Norman H. Cohen" <ncohen@watson.ibm.com>
Subject: Re: GNAT messages and the not operator (pitfall alert!)
Date: 1996/10/29
Date: 1996-10-29T00:00:00+00:00	[thread overview]
Message-ID: <32762A30.D2D@watson.ibm.com> (raw)
In-Reply-To: dewar.846163972@merv


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




  parent reply	other threads:[~1996-10-29  0:00 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-10-24  0:00 GNAT messages and the not operator (pitfall alert!) Robert Dewar
1996-10-24  0:00 ` Robert Dewar
1996-10-25  0:00   ` whiting_ms@corning.com (Matt Whiting)
1996-10-26  0:00     ` David C. Hoos, Sr.
1996-10-27  0:00     ` Robert Dewar
1996-10-28  0:00       ` Matthew S. Whiting
1996-10-26  0:00   ` John Herro
1996-10-26  0:00     ` Matthew Heaney
1996-10-29  0:00       ` Robert Dewar
1996-10-26  0:00     ` Robert Dewar
1996-10-29  0:00       ` John Herro
1996-10-29  0:00         ` Robert Dewar
1996-10-30  0:00     ` Dr. Peter E. Obermayer
1996-10-30  0:00       ` John Herro
1996-10-30  0:00         ` Robert Dewar
1996-11-01  0:00         ` User Password expiration date extractor? Stein-Aksel Basma
1996-10-29  0:00   ` Norman H. Cohen [this message]
1996-10-29  0:00     ` GNAT messages and the not operator (pitfall alert!) whiting_ms@corning.com (Matt Whiting)
1996-10-30  0:00       ` Norman H. Cohen
1996-11-06  0:00         ` Richard A. O'Keefe
1996-11-18  0:00           ` Norman H. Cohen
1996-11-18  0:00             ` Robert Dewar
1996-10-30  0:00       ` David C. Hoos, Sr.
1996-10-30  0:00         ` whiting_ms@corning.com (Matt Whiting)
1996-10-30  0:00           ` Norman H. Cohen
1996-10-30  0:00       ` Robert Dewar
1996-11-05  0:00     ` Robert Dewar
1996-10-28  0:00 ` Cary Jamison
1996-10-29  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