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: mheaney@ni.net (Matthew Heaney) Subject: Re: loop step function Date: 1997/01/25 Message-ID: #1/1 X-Deja-AN: 212170590 references: <32E93C0B.36A@cloud9.net> content-type: text/plain; charset=ISO-8859-1 organization: Estormza Software mime-version: 1.0 newsgroups: comp.lang.ada Date: 1997-01-25T00:00:00+00:00 List-Id: In article <32E93C0B.36A@cloud9.net>, pvanbell@cloud9.net wrote: >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? This is a *deliberate* omission in the langauge. Here is a clue about why Ada doesn't have a step option: Programming is a Human Activity Ada was engineered for use by humans, who tend to make mistakes. It was designed to omit features in other languages that tended to be error prone. Ada was designed for use by human programmers Empirical studies had been done to determine what mistakes were common among human programmers, and one of the mistakes that programmers always make is getting loop termination correct. Figuring out what the last value is during iteration is often difficult and error prone. Ada solves the problem by only allowing a step size of one, thus removing the difficulty and removing the source of error. Just think of Ada's for loop as meaning "this states directly how many times I iterate." And that quantity isn't necessarily the same as the number I use in the algorithm. So Ada's for loop is the no-brainer way to iterate across the values of a discrete type. As Larry pointed out in another post, if you need some other value (that you would use a for-step in another language), then use a local declare block to calculate the value. I've been programming in Ada for 10 years, and I can't remember even one time needing a value other than one as my step value. If I were going to design a glove for use by humans, then I would design it to fit the shape of the human hand. If I were going to design a programming language for use by humans, then I would design it to fit the cognitive capacities of the human brain. That language is Ada. -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271