Migrating To Five One |
|
|
This page attempts to provide more detail on how to move from 5.0 to 5.1 than the [Incompatibilities with version 5.0] section of the Lua 5.1 manual provides. |
|
This page attempts to provide more detail on how to move from 5.0 to 5.1 than the [Incompatibilities with version 5.0] section of the Lua 5.1 manual provides. |
|
{{{ |
|
{{{!Lua |
|
{{{ |
|
{{{!Lua |
|
{{{ if (index < 0 && -index <= top) index = top+index+1; my* = luaL_check*(L, index, ...); |
|
{{{ if (index < 0 && -index <= top) index = top+index+1; my* = luaL_check*(L, index, ...); |
function catchall( ... ) for i=1,arg.n do print( "Argument #", i, "is", arg[ i ] ) end -- Pass all arguments to another function show3( unpack( arg ) ) end function show3( a, b, c ) print( a, b, c ) end catchall( nil, 'two', nil ) --> Argument # 1 is nil --> Argument # 2 is two --> Argument # 3 is nil --> nil two nil
function catchall( ... ) -- Make a new table of values local theArguments = { ... } for i=1,select( '#', ... ) do print( "Argument #", i, "is", theArguments[ i ] ) end -- Pass all arguments to another function show3( ... ) end function show3( a, b, c ) print( a, b, c ) end catchall( nil, 'two', nil ) --> Argument # 1 is nil --> Argument # 2 is two --> Argument # 3 is nil --> nil two nil
ipairs() will stop at the first embedded nil value;
# (the length operator) [may] stop at the first embedded nil value;
table.maxn() will skip embedded nil values; but
select( '#', ... ) will allow you to see that the user passed in trailing nil values.
if (index < 0 && -index <= top)
index = top+index+1;
my* = luaL_check*(L, index, ...);
package.loadlib for 5.0 uses of loadlib