示例工程 01-mental-model

01-mental-model/01-hello-chunk/main.lua

lua · 0.4 KB

-- @runtimes lua54 luajit
--- 演示:最小 chunk 的形态——没有 main,直接执行语句。
 
local M = {}
 
--- 打印问候并返回运行时信息。
--- @return table { version = string, message = string }
function M.run(log)
	log = log or print
	local message = "hello from chunk"
	log(message)
	return { version = _VERSION, message = message }
end
 
if not ... then
	M.run()
end
 
return M