导出函数源代码 |
|
我使用 Tcl 一段时间了,我发现过程“info body <procedures name>”非常方便,我渴望在 Lua 中也能使用它。
string.dump(<function)>) 可以扩展为 string.dump(<function>,<sourcecode?>),如果 <sourcecode> 不为 nil,则返回函数的源代码。
示例
function bla (n) print(n) end print(string.dump(bla,true))
将打印
function (n) print(n) end