[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Exception handling (was Re: ...add to Lua...)
- From: Ivan Krylov <krylov.r00t@...>
- Date: Thu, 20 Sep 2018 23:50:59 +0300
On Thu, 20 Sep 2018 00:12:21 +0200
nobody <nobody+lua-list@afra-berlin.de> wrote:
> From the user code, you call `hopefully( desc, params... )` (could also be
> hidden inside some constructor) and if the action fails, that tries
> the handlers in order (with the stack still intact – so this is a
> normal function, no language support needed etc.).
I'm not sure I understand how it's implemented -- can you somehow
protect a Lua call in such a way that your handler gets executed
at the same place in the stack where the original error() happened? --
but the R language has a similar construct: the tryCatch function.
R imitates pass-by-value semantics for all function arguments by using
lazy evaluation and copy-on-write, so an expression that gets passed to
a function isn't actually evaluated until the function uses it.
tryCatch() employs that and a few more tricks to intervene when the
expression being evaluated calls stop() and to call a matching handler
instead (if it has one supplied).
--
Best regards,
Ivan
- References:
- Re: new thought experiment: what would you add to Lua ?, John Hind
- Re: new thought experiment: what would you add to Lua ?, Alysson Cunha
- Re: new thought experiment: what would you add to Lua ?, Peter Hickman
- Re: new thought experiment: what would you add to Lua ?, Sam Putman
- Re: new thought experiment: what would you add to Lua ?, Alysson Cunha
- Re: new thought experiment: what would you add to Lua ?, Sean Conner
- Re: new thought experiment: what would you add to Lua ?, Sean Conner
- Exception handling (was Re: ...add to Lua...), Dirk Laurie
- Re: Exception handling (was Re: ...add to Lua...), Sean Conner
- Re: Exception handling (was Re: ...add to Lua...), Tim Hill
- Re: Exception handling (was Re: ...add to Lua...), nobody