lua-users home
lua-l archive

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


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