lua-users home
lua-l archive

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

Excuse my ignorance, but is there a “official” (read: preferred/reliable) way to detect that you have run a module directly as a program instead of loading it with require()?

Like the “name == main” trick in Python?

I have seen suggestions to use debug.getinfo() to probe the call stack depth, and testing whether the stack is too shallow to be inside a call to require(). Does that work? Is there a better way?