[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: What is the equivalent of die() command of perl
- From: steve donovan <steve.j.donovan@...>
- Date: Thu, 10 Sep 2009 14:00:53 +0200
On Thu, Sep 10, 2009 at 1:54 PM, Anurag Sharma
> There is a Die command in perl which terminates the program immediately and
> prints the 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.