lua-users home
lua-l archive

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


On Tue, Jan 31, 2012 at 1:46 PM, Francesco Abbate
<francesco.bbt@gmail.com> wrote:
> function when an error was produced. In this latter case the goto
> statement is actually useful to ensure that resource are correctly
> disposed before returning to the caller function. In more high-level
> programming languages this is not necessary because exception handling
> (with or without garbage collector) offer a better alternative.

It depends. There is a cost (syntax and run-time) to exception
handling in Lua.  We know that goto is low-level, but it is not
inherently evil in the hands of someone who knows that it's the most
optimal solution.  And as for 'bad code', the best solution is
education, not limiting the language so that it can be 'safe'
according to the current definition of 'safe'.

Gotos are also useful for code generation, particularly if one has
some kind of #line pragma as well.

steve d.