lua-users home
lua-l archive

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


on 5/10/07 6:08 AM, xolox@home.nl at xolox@home.nl wrote:

> Preprocessing your scripts is one option, but have you considered the
> following (untested):
> 
> function assert(cond, ...)
>    if not cond then error(string.format(...), 2) end
>    return cond, ...
> end
> 
> This should avoid most unnecessary string construction/concatenation. Are you
> worried this will still impact performance? As David suggested, another option
> is CPP

This would be a reasonable option if the meaning of %s in string.format was
changed to do a tostring (or a new escape were introduced to do this).

Slightly odd things can happen if the error message string contains
accidental escape sequences -- e.g,, the name of a file contains a percent
sign and that file name gets included in the error string.

Mark