lua
lua_pcall 是使用 c 中的 setjmp 实现的, 对应在lua 中的函数就是 pcall
pcall/error 大概就相当于其他语言中的 try-catch /throw了
local ok, errorobject = pcall(function()
--here goes the protected code
...
end)
if not ok then
--here goes the error handling code
--(errorobject has more information about the error)
...
end
协程
对称协程只有一个关键字: transfer, 类似于 goto 语句, 把控制权移交给其他的任意一个协程 …