遷移至五點一

lua-users home
wiki

此頁面嘗試提供比 Lua 5.1 手冊的 [與 5.0 版本不相容的項目] 章節更詳細的資訊,說明如何從 5.0 移轉至 5.1。

沒有 table.setn() 和 table.getn() 的生活

使用 vararg 表達式,而非「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

嵌套長字串或區塊註解

處理垃圾回收機制

簡單的「尋找/取代」變更

字串為「物件」

C API 變更

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

將附掛或函式庫與特定遷移

新的模組系統


最近的變更 · 偏好設定
編輯 · 歷史記錄
2007 年 1 月 11 日格林威治標準時間凌晨 3:50 最後一次編輯 (diff)