Lua Five Three

lua-users home
wiki

Lua 5.3 將很快成為繼 5.2 之後的 Lua 最新重大版本。本頁提供有關 5.3的一些注意事項。Lua 5.3 的官方資訊和下載網址可在 https://lua.dev.org.tw/manual/5.3 找到。

在此處可找到 5.2 和 5.3 之間的差異摘要

公告

Wiki 上也描述了受影響的部分,包括

本頁可能討論的其他部分:LuaJIT?和 LuaImplementations?IDE 支援?

table.move

table.move (a1, f, e, t [,a2]) https://lua.dev.org.tw/work/doc/manual.html#pdf-table.move

此新函式複製一系列值。

就設計而言,此函式類似 C memmove [1] 函式,但並非以其為基礎實作。來源和目標範圍可能重疊(與 C memcpy 不同)。

table.move 也提供一種清除(全部或一部份)陣列的便利方式

table.move(a, #a+1, 2*#a, 1)

table.move 在 5.3.0(alpha) 中以前稱為 table.copy

table.move 內部是以 lua_geti/lua_seti [2][3] 或(如果 t 缺乏 __index/__newindex 元方法)lua_rawgeti/lua_rawseti [4]/[5] 實作。(參閱 ltablib.c 中的 checktab/aux_getntmove。)

lua_rotate

void lua_rotate (lua_State *L, int idx, int n); https://lua.dev.org.tw/manual/5.3/manual.html#lua_rotate

討論

觀察 lua_insertlua_remove 在 lua.h 中對 lua_rotate 的定義

#define lua_insert(L,idx)	lua_rotate(L, (idx), 1)
#define lua_remove(L,idx)	(lua_rotate(L, (idx), -1), lua_pop(L, 1))

arg

自述檔上說:「arg 表單可用於所有程式碼」。

討論

「使用者資料可以使用任何 Lua 值作為使用者值」

討論


最近異動 · 偏好設定
編輯 · 歷史紀錄
上一次編輯:2018 年 3 月 1 日 上午 9:09 GMT (diff)