[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Try-catch and try-finally
- From: steve donovan <steve.j.donovan@...>
- Date: Tue, 31 May 2016 14:11:28 +0200
On Tue, May 31, 2016 at 1:39 PM, Alysson Cunha <firstname.lastname@example.org> wrote:
> In a simple example of file transfer over the internet, unexpected things
> can occur in the middle of the process and it is a good pratice ensure that
> the "file handle" will be closed at the end no matter what. In these case, a
> try-finally statement would be very useful.
Ah, but we use pcall for that - try/except in Lua would be sugar for that idiom.
Sugar is fine when it does not have any runtime costs (e.g. a:f(b) is
short for a.f(a,b)) but in this case a closure would be silently
I tend to side with Jonne here - exceptions are overused. It's easy to
check if a file exists, why throw an exception to be handled dozens of
stack frames down? (--> Java <---)