comp.lang.ada
 help / color / mirror / Atom feed
From: t-wader@microsoft.UUCP (Wade Richards)
Subject: Re: bug me now / bug me later
Date: 11 Jun 90 22:19:17 GMT	[thread overview]
Message-ID: <55151@microsoft.UUCP> (raw)
In-Reply-To: 811@sagpd1.UUCP

In article <811@sagpd1.UUCP> jharkins@sagpd1.UUCP (Jim Harkins) writes:
=}
=}Lets say you have the following (you ADA people, please bear with me):
=}
=}	#define SIZE	6
=}	#define STEP	2
=}
=}Which is better:
=}
=}	a.	for(i = SIZE; i != 0; i -= STEP)
=}or
=}	b.	for(i = SIZE; i > 0; i -= STEP)
=}

It depends on the situation. 

If you know that i will exactly equal zero (as in this case), then I think
that's what you should test for.  However, I would probally put:

assert( SIZE % STEP == 0 )

before the loop, to make sure nothing blows up, and (more importantly) to make
it quite clear what was at fault if it does blow up.


	--- Wade

  parent reply	other threads:[~1990-06-11 22:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1990-06-07 23:26 bug me now / bug me later Jim Harkins
1990-06-08 16:51 ` Charles H. Sampson
1990-06-11 22:19 ` Wade Richards [this message]
1990-06-12 13:36 ` Robert Firth
1990-06-14  5:22   ` brnstnd
1990-06-14 15:00     ` David Kassover
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox