lua-users home
lua-l archive

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


Roberto,

In llimits.h luai_assert() is defined as lua_assert() if LUA_USE_APICHECK is not defined. Which means if lua_assert() is defined then luai_assert() automagically works too. :)

I have been really getting up to my elbows in Lua's internals, and having a really fun time with it! There is a bit of a learning curve with understanding the internals, but I think I am starting to grok it! Expect some power patches soon! ;)

I am pretty sure I enabled LUA_USE_APICHECK initially, and then discovered defining lua_assert() directly as assert() to do even more error checking. I will also check out the ltests.* files, thank you for bringing those to my attention!

~pmd~

PS: Thank you, and your colleagues, very much for Lua! <3


 
On Nov 13, 2013, at 5:19 AM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:

>> I think you meant that "#define lua_assert(x) assert(x)" is all I need?
>> 
>> Just defining LUA_USE_APICHECK does not change lua_assert() at all, and if I only define LUA_USE_APICHECK then lua_assert(0) does not cause an assertion. However, if I remove the LUA_USE_APICHECK define but do define lua_assert() then luai_apicheck() will also assert. :)
> 
> I think there are two different things here. LUA_USE_APICHECK does not
> need lua_assert, as it defines luai_apicheck using assert directly.  As
> its name implies, it checks only the API, not Lua internals.  (Usually
> this is what people want.) However, if you are hacking the *insides* of
> the Lua kernel, then it may be worth defining lua_assert. You can also
> consider using ltests.h/ltests.c (distributed with the test files),
> which defines lua_assert and some other checks (e.g., a basic allocator
> check).
> 
> -- Roberto
>