blt4linux / blt4l

PAYDAY 2 SteamOS/Linux LUA loader.
Other
57 stars 14 forks source link

Make pcall return proper message value on failure #94

Closed ZNixian closed 7 years ago

ZNixian commented 7 years ago

Makes the pcall function return the error message as a second return value on failure, as per the Lua specifications.

See #92

RomanHargrave commented 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?

ZNixian commented 7 years ago

The number you return is the number of arguments that are returned in Lua.

RomanHargrave commented 7 years ago

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.

ZNixian commented 7 years ago

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.