lua-users home
lua-l archive

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


On Mon, 19 Jan 2009, John Belmonte wrote:

>    2. Should this enhancement allow distinguishing of "exit" from
> "exit by error"?

I'd actually argue for "not usually, if ever"

>       Yes.  A common use of the popular "try-catch" construct is
[snip]

It's hard to argue against _allowing_ to distinguish errors from 
non-errors, but I'd just like to drive home the point that since 
resources usually need to be closed the same way in an error vs. 
successful exit, there ought to be just one code path for cleaning 
them up.  A try/catch construct is a bad model to follow for resource 
cleanup primarily because it distinguishes exceptional circumstances 
from normal ones leading to code duplication and rarely tested code 
paths.  For the exceptional cases let there be exceptional code, I 
say.  Not that you were headed for a try/catch construct.

Cheers,

Joonas