"for" loops (was Re: C++ vs. Modula
flint at gistdev.UUCP
flint at gistdev.UUCP
Wed Feb 1 02:43:00 AEST 1989
I've always felt that it should be the job of programming languages to let
me say what I want to do concisely, and then they should do it the way I
want. Therefore, there is no reason I can see that the language should not
let you have an increment of .1, since it is quite clear exactly what I
want it to do in this case: the compiler ought to be able to see (easily)
that it needs to set up a dummy integer counter to actually control the
loop, and divide by 10 at the top of the loop for you to give you the index
you use. By doing so, it allows experienced people to do less typing, and
protects beginners from their ignorance- you win both ways. (It cannot
necessarily deal with the round-off problems at the end of the loop of
course: in the example cited, the question was whether to run the loop for
10 or 11 iterations. However, if the compiler does one division to make
that decision & then codes an integer loop for you it's much more likely
it will be what you wanted.)
Flint Pellett, Global Information Systems Technology, Inc.
1800 Woodfield Drive, Savoy, IL 61874 (217) 352-1165
INTERNET: flint%gistdev at uxc.cso.uiuc.edu
UUCP: {uunet,pur-ee,convex}!uiucuxc!gistdev!flint
More information about the Comp.lang.c
mailing list