Migrating To Five One

lua-users home
wiki

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.

Living without table.setn() and table.getn()

Using vararg expressions rather than 'arg'

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

Nesting long strings or block comments

Working with Garbage Collection

Simple Find/Replace Changes

Strings as 'objects'

C API Changes

if (index < 0 && -index <= top)
    index = top+index+1;
my* = luaL_check*(L, index, ...);

Migrating with Specific Addons or Libraries

New Module System


RecentChanges · preferences
edit · history
Last edited January 11, 2007 3:50 am GMT (diff)