[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: assert with formatting
- From: Sean Conner <sean@...>
- Date: Fri, 13 Jul 2018 09:45:52 -0400
It was thus said that the Great Javier Guerra Giraldez once stated:
> On 13 July 2018 at 09:00, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> > assert( a==1, ('`a` should be `%d`, but was `%s`'):format(1,a) )
> >
>
> slightly suboptimal, since the message is composed even if the assert succeeds.
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.
-spc