lua-users home
lua-l archive

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



On Fri, Jan 17, 2014 at 9:47 AM, Justin Cormack <justin@specialbusservice.com> wrote:
But the failure case of assert is not a fast path (obviously the
success case is), and it is basically similar to calling error() which
was fixed to use __tostring in metatables... So it looks more like an
oversight to me...


Hmmm.... I can't see anything wrong with that, especially since the result is an error. This is especially insidious with assert (not so much with error, where you can say `error(tostring(something))`)

In cases like: `assert(a==b, tostring(some error thing))` it's the same.

But when nil, erro_obj is returned by your function and you type `assert(myfunc())`, it'd be more... consistent without affecting the fast path.

Seems like it would be nicer if assert respected __tostring, as error does. Whenever I think this, someone explains a great answer for it. In three, two, one...