lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 19/05/2010 21:57, Petite Abeille wrote:
Also, while we are at it, drop the while and repeat statement as well. How many loopy
[sic] constructs does a language need?

while exp do block end
repeat block until exp
for Name `=´ exp `,´ exp [`,´ exp] do block end
for namelist in explist do block end

Sure, we can do all of this with a good old GOTO, after all.

On 19/05/2010 22:01, Alexander Gladysh wrote:
>> FWIW, I would second that. Drop the numeric loop.
>> And keep ipairs alongside the generic for statement.
>
> Err... How would you write this then?
>
> for i = 1, 100 do
>    print("I would never use numeric for again")
> end

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.

--
Philippe Lhoste
--  (near) Paris -- France
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --  --  --