(function()
print(1)
if true then
return
end
print(2)
end)()
function f()
a = 1
function f1()
print(a)
end
f1()
end
f()
-- require 其他的模块
-- local ngx_lua 相关的 api
-- local lua 相关的函数(再把 lua 相关的独立出来)
local utils = require "modules.utils"
local metadata = require "modules.metadata"
local cjson = require "cjson.safe"
local get_method = ngx.req.get_method
local get_uri_args = ngx.req.get_uri_args
local null = utils.null
local str_gsub = string.gsub
<if-statement> and <true_result> or <false_result>
- http://gin.io/
- lapis
- vanilla
- LuaDist
- LuaRocks
lua_xxx
主要是 lua 基本 APIluaL
是封装过的基本 API
- http://dhq.me/by_keyword/397/lua?page=3#content-pager
- http://coolshell.cn/articles/10739.html
- http://lua-users.org/wiki/TutorialDirectory
- build: Tools -> Build System -> New build System, 主要lua要用绝对路径否则找不到.
{
"cmd": ["/usr/local/bin/lua", "$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.lua"
}
只能用于build, 不能传参数, 相当于lua [filename.lua].
brew install lua luajit metalua luarocks
luarocks install luasocket
- https://lua-toolbox.com
- lua luac luajit metalua luarocks
- eclipse: ldt
- sublime text
- idea: plugin https://bitbucket.org/sylvanaar2/lua-for-idea/wiki/Home
- ZeroBrane: http://www.jianshu.com/p/271db393cf58
- luasocket
- lua-log: https://github.com/moteus/lua-log
- luvit: Lua + libUV + jIT = pure awesomesauce http://luvit.io/
- http://stackoverflow.com/questions/8531446/good-logging-library-for-lua
- http://www.inf.puc-rio.br/~roberto/lpeg/