[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: state of the Lua nation on resource cleanup
- From: M Joonas Pihlaja <jpihlaja@...>
- Date: Fri, 13 Feb 2009 13:44:35 +0200 (EET)
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