[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: How to tell if this is the top-level script?
- From: Geoff Leyland <geoff_leyland@...>
- Date: Thu, 6 Sep 2007 19:52:59 +1200
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