lua-users home
lua-l archive

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


On 09/10/2014 11:48 AM, Newton Kim wrote:
check_exp evaluates an expression with lua_assert.
But lua_assert is not defined in the source code.
llimits.h defines it with (void)0 when no definition about lua_assert is available (llimits.h:61~69).
after all, check_exp macro skips the evaluation because lua_assert is NULL.
Although I can work around with defining my lua_assert, I don't think that it's a good idea to leave the macro ( or the function) up to another developers other than lua core developers.
Here, I have some questions.
1. Why do to leave lua_assert undefined?
2. What is the best practice to define lua_assert?
3. Do you have plan to define lua_assert in lua core?
Thank you in advance.
Best regards,
Newton.

the `Lua core' is an ebeddable library. various diagnostic facilities are there in the core
codebase serving different purposes.

for developers who embedded Lua into their projects, adding `-dLUA_USE_APICHECK` to CFLAGS
would be propriate in most cases, which checks the paremeters passed to the Lua API.

the `lua_assert` macro is mainly used by the core developer to catch BUGS inside the Lua core,
those who just use/embed Lua need not bother with `lua_assert` most of the time.

if you really need it (i.e. you are using a customized/patched Lua engine), it is your own
resposibility to provide a proper assertion definition. you can report failures using a pop-up
diaglog, for example, or you can `longjmp` to some protection point on failure, or you can
simply use the definition in the <assert.h> which would print messages to stderr and call `abort'.