[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: about 'fail'
- From: Phil Leblanc <philanc@...>
- Date: Sat, 5 Oct 2019 20:35:54 +0000
1) I understand that 'fail' is not a literal value (such as 'true'),
and not a reserved word. Is it correct to say It is a variable name
which happens to be undefined, and so evaluates to nil?
2) Does the Lua team encourage C extension developers to use
luaL_pushfail(L) instead of lua_pushnil(L)? if yes, maybe
luaL_pushfail should be documented in the manual, section 5.
3) Do you encourage Lua library developers to update their libraries
and start using use the idiom "return fail, msg" in case of error
(instead of "return nil, msg")?
If yes, I would recommend a big warning somewhere in the manual
(where?) and also in every "new style" library documentation: If such
a library is used in a program which happens to define 'fail' as a
global variable, it may be an issue.
An option would be for library developers to systematically add a
"local fail = nil" at the beginning of their modules (or "assert(not
fail)")
4. As Roberto explained:
> "So, the motivation for the change is to move our minds from the concept that errors return (nil,msg) to the concept that errors return (falsy,msg). Maybe one day in the distant future we might change that falsy to false instead of nil."
So would you encourage developers to start using "return false, msg"
in case of error instead of return nil, msg ?
TIA,
Phil