[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: level argument for assert
- From: Thijs Schreijer <thijs@...>
- Date: Thu, 3 Jan 2013 10:13:09 +0000
> > 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