[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.0 (work3) now available
- From: steve donovan <steve.j.donovan@...>
- Date: Thu, 20 May 2010 09:48:23 +0200
On Thu, May 20, 2010 at 9:39 AM, Philippe Lhoste <PhiLho@gmx.net> wrote:
> In JavaFX, for example, we have to write:
>
> for (i in [ 1 .. 100]) println("...");
>
> ie. we have to generate a sequence (kind of array) filled with increasing
> numbers from 1 to 100 to iterate on it. I suppose the compiler optimizes
> that, ie. that the sequence is virtual, not taking up memory.
Yes, exactly what the 'for l in range(0,10): ' does in Python - they
have xrange() that gives an iterator. Personally, I can't understand
why people don't like the numeric-for. It's fast and expresses a
common pattern in a well-understood fashion.
But then I don't understand why ipairs has to go either - not much
code involved. Again, it is a well-understood pattern that we all
know, why throw it away? Alexander says that it it is significantly
slower than numeric-for, but this is only the kind of thing you will
notice with trivial loop payloads. So the definition of 'significant'
is in question here.
steve d.