[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: for loops
- From: Diego Fernandes Nehab <diego@...>
- Date: Fri, 31 Oct 1997 14:18:49 -0200
Alan Watson wrote:
> If you are going to add "for" loops, then I urge you to restrict
> yourself to loops like "for i = 1 to 10 do ... done" and "for i in
> table do ... done".
I also miss for loops, very much. The one who never wrote something like
while i < 10 do
something(i)
end
and, for a second or two, wondered why the program was not working can
say for loops have no use. One has always to remenber defining the
counter variable and incrementing it within the while loop, something
obvious with for loops.
Also, I agree with the simple syntax. One would prefer using while loops
then writing all the "for-then-while-do-end" stuff.
I would suggest the counter specified in the for declaration to be
local. That is:
i = 7
for i=10 to 1 do
something(i)
end
print(i)
should print the value 7, leaving the global i unchanged. That would
avoid a lot of problems of "counter sharing" between loops.
I also miss, even more than for loops, break and continue as in C. I
have already discussed the matter briefly with Roberto and he has some
neat ideas on the subject. Since we are discussing about possibilities
for the next version, why not discuss this also?
Diego Nehab.