lua-users home
lua-l archive

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


On Thu, Feb 28, 2008 at 11:23 PM, Mike Pall <mikelu-0802@mike.de> wrote:
>   assert(type(x) == "number")
...
>  Summary: you can leave those assert()'s in with LuaJIT 2.x. But
>  write them in plain Lua and not in specialized C functions. These
>  are black boxes for the compiler and cannot be optimized away.

That's great to hear. I have systematically added such assert()'s to
all function arguments in the code of LuaRocks (and things such as
assert(type(x) == "number" or not x) for optional arguments). They're
somewhat annoying to write (and at times it looks weird that a
function is three lines long and two of them are type assertions), but
they have proven useful quite a few times already.

-- Hisham