lua-users home
lua-l archive

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


Wednesday, May 18, 2005, 11:23:24 AM, you wrote:

>> for c in next,mytable do print(c) end
>> 
>> Prints:
>> 
>> 1
>> 
>> and then hangs.

On WinXP compiled with MinGW this seems to be OK. So it is probably a
MSVC problem.

C:\MinGW\local\bin>lua
Lua 5.1 (work6)  Copyright (C) 1994-2005 Tecgraf, PUC-Rio
> for c in next,mytable do print(c) end
stdin:1: bad argument #1 to '(for generator)' (table expected, got nil)
stack traceback:
        [C]: in function '(for generator)'
        stdin:1: in main chunk
        [C]: ?
> for c in next,{} do print(c) end
> for c in next,{1,2} do print(c) end
1
2
> for c in mytable do print(c) end
stdin:1: attempt to call a nil value
stack traceback:
        stdin:1: in main chunk
        [C]: ?
> for c in {} do print(c) end
stdin:1: attempt to call a table value
stack traceback:
        stdin:1: in main chunk
        [C]: ?
> for c in {1,2} do print(c) end
stdin:1: attempt to call a table value
stack traceback:
        stdin:1: in main chunk
        [C]: ?
> mytable = {3,4}
> for c in next,mytable do print(c) end
1
2
>
> for c in mytable do print(c) end
stdin:1: attempt to call a table value
stack traceback:
        stdin:1: in main chunk
        [C]: ?
> for k,v in pairs(mytable) do print(k,v) end
1       3
2       4
>

e