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,2acb7591d4833271 X-Google-Attributes: gid103376,public From: kilgallen@eisner.decus.org (Larry Kilgallen) Subject: Re: loop step function Date: 1997/01/25 Message-ID: <1997Jan24.192209.1@eisner>#1/1 X-Deja-AN: 212089334 x-nntp-posting-host: eisner.decus.org references: <32E93C0B.36A@cloud9.net> x-nntp-posting-user: KILGALLEN x-trace: 854151740/28126 organization: LJK Software newsgroups: comp.lang.ada Date: 1997-01-25T00:00:00+00:00 List-Id: In article <32E93C0B.36A@cloud9.net>, Paul Van Bellinghen writes: > I'm fairly new to ADA. I have coded in PASCAL, FORTRAN, C, and assembly > and have found ADA to be similar to PASCAL but with stronger type > checking and with better organization and data hiding. Anyway, there > seems to be an obvious omission in the ADA language. The FOR loop does > not have a "STEP" option. In order to perform a loop function using a > variable's range of values but in steps greater than the variable > kernel, you seem to have to use a WHILE loop with the variable > incremented within the loop by the step size. Is there a more elegant > way of doing this? In order to shed the newcomer image, you have to capitalize it as Ada with this crowd. Pretty silly for a language which is case-insensitive, but everything else is much more logical. As regards FOR loops, you could say: for BY_ONE from 1 to 20 loop declare USEFUL_VALUE : INTEGER := BY_ONE*2; begin my_procedure ( USEFUL_VALUE ); end; end loop; Whether that is "elegant" is certainly debatable, but it is "flexible" in that: USEFUL_VALUE : INTEGER := BY_ONE*2; could be replaced with: USEFUL_VALUE : INTEGER := (BY_ONE**2)/13; Larry Kilgallen The above statements represent my "gut feel" and have not been authorized by any compiler.