lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


My impl:

function try(t)
local ok,msg = pcall(t[1],t)
if not ok then
return function(tt) tt["catch"](msg,t) end
else
return function(tt) if tt["finally"] then tt["finally"](t) end end
end
end


print(try{
function(self)
print"..."
self.step=1
print("hi~"..xxxx);
self.step=2
print"..."
end
}({ catch=function(msg,t) print("catch after step",t.step,msg) end,
finally=function(t) print("finally to step",t.step) end
})

)


--
Regards,
Linker Lin
linker.m.lin@gmail.com