lua-users home
lua-l archive

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

On Wed, May 19, 2010 at 6:51 AM, Nikolai Kondrashov <> wrote:
> I wasn't able to find an answer to a seemingly basic question anywhere:
> Is it possible to disable "assert" function execution along with its
> argument evaluation in Lua? I.e. like it is done in C by defining NDEBUG?

An observation: In many languages [1], asserts are clearly
distinguished from normal error handling: assert calls should have no
meaningful side-effects, so you may safely strip them, and any assert
failure indicates a defect in the program.  In Lua, assert is also
conventionally used for its convenience in converting normal error
return values into raised exceptions (the inverse of pcall).  The Lua
manual contains one such possible example: assert(loadstring(s))() .
This we might say is an abuse of the normally recognized concept of
assert and could call for splitting assert into two separate functions
(even if they be implemented identically).