lua-users home
lua-l archive

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


Hi,

For a while I've been writing my Lua modules like this:

if ... then module(...) end

and at the end of the module:

if not ... then
-- do some tests or something suitable when called as a top-level script
end

Which worked really nicely - I could use the code as a module, or get it to run its self-tests without fuss.

However, it's stopped working, possibly since I upgraded to 5.1.2 or since I started using LuaBinaries - the error is on the "if not ... then" line, and says "cannot use '...' outside a vararg function".

Does anyone have any suggestions as to how to achieve the same thing (work out if we're being run as someone else's module or as a top- level script) a better way?

Thanks in advance,
Geoff