[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: assert with formatting
- From: Dirk Laurie <dirk.laurie@...>
- Date: Fri, 13 Jul 2018 18:17:08 +0200
2018-07-13 16:23 GMT+02:00 Pierre Chapuis <catwell@archlinux.us>:
>> 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.