[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Numeric for loops...
- From: Jonathan Castello <twisolar@...>
- Date: Sat, 29 May 2010 00:27:55 -0700
On Sat, May 29, 2010 at 12:21 AM, duck <duck@roaming.ath.cx> wrote:
>
> 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?
>
I think it's slightly lamentable that "for i=1, 10, 100" is almost
identical to "for i in 1, 10, 100", but that's just me. I definitely
think ipairs() should stay in some form.
> 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)
>
I dearly miss +=, -=. *=, and /=.
~Jonathan