|
On Wed, May 19, 2010 at 6:51 AM, Nikolai Kondrashov <spbnick@gmail.com> wrote:An observation: In many languages [1], asserts are clearly
> 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?
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).
[1] http://en.wikipedia.org/wiki/Assertion_(computing)