Lua 中使用的文档类型约定是什么?

Ans*_*iņš 5 lua conventions typing

我来自强类型世界,我想编写一些 Lua 代码。我应该如何记录事物的类型?Lua 本地人做什么的?匈牙利记数法?还有别的事吗?

例如:

local insert = function(what, where, offset)
Run Code Online (Sandbox Code Playgroud)

一眼就能看出我们这里讨论的是字符串还是表。

我应该做什么

local sInsert = function(sWhat, sWhere, nOffset)
Run Code Online (Sandbox Code Playgroud)

或者

-- string what, string where, number offset, return string
local insert = function(what, where, offset)
Run Code Online (Sandbox Code Playgroud)

或者是其他东西?

局部变量呢?表格条目(例如)怎么样someThing.someProperty

小智 4

有关社区(或特定社区?)中 Lua 风格的想法和意见的参考,请阅读:LuaStyleGuide

最接近强制样式的是LuaDoc使用的格式,因为它是 LuaFileSystem 等知名项目使用的相当流行的文档生成器。