lua-users home
lua-l archive

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

2018-07-13 16:23 GMT+02:00 Pierre Chapuis <>:
>>   Um, but wouldn't
>>   format_assert(a == 1 , "'a' should be '%d', but was '%s'",1,tostring(a))
>> *also* compose the message even if a equals 1?  Lua doesn't do lazy
>> evaluation.
> It would call `tostring(a)` in all cases, but it would not call `string.format` because that branch of the `if` would never be evaluated.
> I am not entirely sure if there is a real performance gain, though.

'assert' is not about performance. It is about catching blunders at a
point where you hope you can track them.