lua-users home
lua-l archive

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


On Tue, May 31, 2016 at 2:21 PM, Jonne Ransijn <yoyoyonny@gmail.com> 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
concise:

try
    do: ->
        print a.x
    catch: (e) ->
        print 'error!',e
    finally: ->
        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.

https://github.com/leafo/moonscript/wiki/Exception-handling