lua-users home
lua-l archive

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


> > That is indeed a nasty one. But still very annoying that there is no
> level on an assert call. Any ideas on how to add such a thing without
> breaking anything?
> 
> I think what you're looking for is not called assert().  Some Lua lib

Why not? Assert does a check and calls error, so being able to provide level seems reasonable to me?

> functions are already dangerously overloaded (think of table.insert) and
> I've often found myself 'being clever' with overloading.
> 
> This assertl is straightforward to write, at least.

Overloading is tricky unless completely safe. Just tried;

    assert(condition, [[level, ] message,] ...)

assuming that detecting the difference between a string (message) and number (level) would be enough. But unfortunately the current assert coerces numbers to strings for the message argument, so that's also not safe.

Thijs