Closed ZNixian closed 7 years ago
From a logical perspective, this makes sense. That being said, I don't really follow lua. Does signaling a return value (return >0) versus not doing so (return 0) affect behavior at the scripted callsite?
The number you return is the number of arguments that are returned in Lua.
The number you return is the number of arguments that are returned in Lua.
This I know. What I was asking was, does this affect what has to be done at the callsite.
I suppose it doesn't, if it's being used as it currently is.
No. Here's how it's currently normally used:
local success = pcall(...)
if not success then
...
end
Since the first argument returns false
instead of nil
when it fails, there is no difference as far as using it in an if
condition.
If someone passes back a function argument as the second parameter and checks it's not nil
to see if the function ran successfully, that will break. However, relying on the BLT implementations behaving differently to the Lua specification is problematic anyway.
Makes the
pcall
function return the error message as a second return value on failure, as per the Lua specifications.See #92