[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Disabling assert function
- From: David Manura <dm.lua@...>
- Date: Wed, 19 May 2010 22:42:30 -0400
On Wed, May 19, 2010 at 6:51 AM, Nikolai Kondrashov <email@example.com> 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 , 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).