lua-users home
lua-l archive

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

On Thu, Sep 10, 2009 at 1:54 PM, Anurag Sharma
<> wrote:
> There is a Die command in perl which terminates the program immediately and
> prints the message
> Die("Message");
> Is there any equivalent in Lua.. If yes, what is it?

Well error("message") would work, but you would also get a stack
trace, which is not always so friendly for your users. So people will
often do this, which gives a message and no stacktrace.

function die (msg)

You can say things like this:

a = myfunction() or die 'myfunction failed!'

(note that the () is not necessary for functions with single string arguments)

But you can't do this

myfunction() or die 'finished!'

Because expressions in Lua cannot be statements.

steve d.