lua-users home
lua-l archive

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

Hi all,

Is there a 'good' way of removing assertions from code at run/compile
time? I want to keep them around in the source so that I can use them
for debugging, but I'd also like to turn them off to make things as fast
as possible (I am testing something for performance). I poked around in
the mailing list archives and on Google but didn't see anything.

Ideally, everything inside the assert would simply disappear, so that
the error message would not have to be constructed either.

For instance, this entire statement should just disappear:

assert(self.assignment[var] == nil, "var '" .. var .. "' already had
value '" .. (self.assignment[var] or "nil") .. "'")

One solution would be to preprocess the source using e.g. a perl script
and pipe that to luac. Then I would run from source when debugging and
from bytecode when timing. Is this a reasonable idea?

- David