[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Possible bug in lua_next() ?
- From: Pedro Miller Rabinovitch <pedro@...>
- Date: Tue, 18 Dec 2001 18:32:26 -0200
Hullo everybody,
I'm quite stumped with some weird foreach() behavior I met in lua-4.1-work. The following code:
----
table = { n = 0 }
for i = 1, 4 do
tinsert(table, i)
table["i_"..table.n] = i
end
print"Using `foreach':"
foreach(table, print)
print"Using `for i,v in':"
for i,v in table do print(i,v) end
----
...should of course print the same thing both when using `foreach()' and the `for' keyword (it should, shouldn't it? I've RTFM, and as far as I understand, both forms should be equivalent... right?).
However, on my LinuxPPC box it doesn't, printing instead:
Using `foreach':
1 1
2 2
3 3
4 4
Using `for i,v in':
1 1
2 2
3 3
4 4
i_4 4
i_1 1
i_2 2
i_3 3
n 4
The bug doesn't manifest itself for all values of `i' -- only some work (e.g., 2, 4, 9, 10, 11, 20). How quaint and nice of it.
I've ran the code above in a typical run-of-the-mill RedHat 7.2 distro and it worked perfectly -- your mileage might vary. In both cases, I pretty much compiled Lua as it was, just adding debug info and the READLINE option.
Any ideas on why this is happening? I'll try and debug it if I get the time...
Kind regards to all,
Pedro.
--
Pedro Miller Rabinovitch
Diretoria de Tecnologia
Cipher Technology
http://www.ciphertech.com.br
______
"Segurança em TI - uma especialidade Cipher Technology"