[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Removing debug assertions
- From: Mark Hamburg <mhamburg@...>
- Date: Thu, 10 May 2007 08:30:19 -0700
on 5/10/07 5:20 AM, David Haley at email@example.com wrote:
> For instance, this entire statement should just disappear:
> assert(self.assignment[var] == nil, "var '" .. var .. "' already had
> value '" .. (self.assignment[var] or "nil") .. "'")
That's also a prime example of why one would want to drop out such
assertions. In a debug build, you might not care that it always builds the
error string, but in production code it could be a real annoyance.
The efficient way to write this if you don't want the extra overhead is:
if self.assignment[var] ~= nil then
local errorMessage = "var '" .. tostring(var) ..
"' already had value '" .. tostring(self.assignment[var]) ..
That's a lot more typing, however, and hence people will tend to just use
Now, if assert were a macro...