numeric for statement

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

numeric for statement

fschmidt
Administrator
The Lua syntax of the numeric for statement is ugly.
for i = 1,10 do
	print(i)
end
print()
for i = 10,0,-1 do
	print(i)
end
I would like to change it to:
for i = 1 to 10 do
	print(i)
end
print()
for i = 10 to 0 step -1 do
	print(i)
end
This syntax comes from Basic and I think it is much more readable.
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: numeric for statement

Hugo <Nabble>
I agree.
Reply | Threaded
Open this post in threaded view
|

Re: numeric for statement

fschmidt
Administrator
done in rev 34, closing thread
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: numeric for statement

fschmidt
Administrator
In reply to this post by fschmidt
I will add support for the Lua standard as well for compatibility.
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: numeric for statement

fschmidt
Administrator
done in rev 107, closing thread
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: numeric for statement

fschmidt
Administrator
In reply to this post by fschmidt
I changed my mind on this again.  I think Python does this right, having no numeric for statement and instead having a range() iterator.  This means one less concept.  So instead of:
for i = 1,10 do
	print(i)
end
print()
for i = 10,0,-1 do
	print(i)
end
I now have:
for i in range(1,10) do
	print(i)
end
print()
for i in range(10,0,-1) do
	print(i)
end
This was done in rev 110.
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture