[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:29:28 +0200
On Tue, May 31, 2016 at 2:21 PM, Jonne Ransijn <firstname.lastname@example.org> wrote:
> For Moonscript, perhaps, but for Lua, neither of these sound like viable
> goals to me.
Of course, it's 'cleaner' to implement in Moonscript (which doesn't
have built-in sugar for this) because function creation is very
catch: (e) ->
print 'gets here'
But to make the point about hidden costs, there's a table creation and
_three_ closures created here!
This is a strawman example (because any sensible person would just go
'if a then...') but it's not a magic solution to the issues that
Alysson describes - a Lua-friendly solution to those unexpected I/O
problems would use coroutines, so time-outs don't completely mess with
your program's chi. Idiomatic Python/Java exception handling assumes
separate threads of execution for I/O requests.