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.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Xref: utzoo comp.lang.c:29452 comp.lang.ada:3918 Path: utzoo!attcan!uunet!cs.utexas.edu!sdd.hp.com!ucsd!nosc!cod!sampson From: sampson@cod.NOSC.MIL (Charles H. Sampson) Newsgroups: comp.lang.c,comp.lang.ada Subject: Re: bug me now / bug me later Keywords: philosophical differences Message-ID: <1946@cod.NOSC.MIL> Date: 8 Jun 90 16:51:52 GMT References: <811@sagpd1.UUCP> Reply-To: sampson@cod.nosc.mil.UUCP (Charles H. Sampson) Organization: Naval Ocean Systems Center, San Diego List-Id: 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) > >Where this makes a difference is suppose SIZE is changed to 7. Obviously >'a' goes into an infinite loop, while 'b' stops. In the real world SIZE and >STEP could be variables that have been input by a user and manipulated a >gazillion times before being used in the for loop. > Neither is inherently better than the other; it depends on the problem. If the problem requires that SIZE be a multiple of STEP, then a is preferable because it reflects the problem requirement, but the requirement itself must be validated at some point. If there is no required relation between SIZE and STEP, then b reflects that fact and is preferable. (Of course, a is wrong in the latter case, so b is strongly preferable.) All of this is MHO, naturally. Charlie Sampson, CSC P. S. Anything written down here can be ignored. The poster would not ac- cept my followup because I had included more than I had written. Strange, I thought I had cut down the original article to the minimum needed to es- tablish the context, then gave a compact response. Apparently that's not good enough. The only solution in such a case seems to be to pad your followup enough to get past that limitation. Seems to me that the limita- tion is self-defeating. This is the end of my first try at padding.