[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Numeric for loops...
- From: duck <duck@...>
- Date: Sat, 29 May 2010 17:21:50 +1000 (EST)
The numeric 'for' loop is so simple, so quick, so easy to explain, so
commonplace in programming (and so commonly provided in programming
languages), and so jolly useful that I would like to suggest that we all
agree to stop calling for its removal :-)
Lua has comparatively little redundancy compared to other languages. The
sheer convenience and compactness of being able to write the short and
sweet:
for i = 1,#list do
...
end
surely justifies keeping the construct for ever?
We might as well argue to have only one sort of loop (no while, no repeat
-- express them all with iterators, and to hell with readability), or to
get rid of the '-' and '/' operators in favour of recondite stuff like:
difference = amountdue + math.negative(amountpaid)
and:
threequarters = 3 * math.reciprocal(4)
PS: I feel less strongly about ipairs() than about for i=1,n, but would
like to see ipairs() reprieved officially -- not even deprecated :-)