lua-users home
lua-l archive

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

On Tue, Jan 20, 2009 at 6:50 PM, Petite Abeille wrote:
> What's wrong with pcall?
> What about something along these lines.:
> Try( Function, ... )( Catch, Finalize )

Which is roughly one of the two solutions in Lua Programming Gems,
Chapter 13 (some other solutions in decision #5 can be implemented in
terms of pcall as well).  Some arguments given against a pcall
implementation are that an unpatch pcall can interfere with coroutines
(which of course can be patched), returns and breaks inside the try
"block" don't have their usual block-level semantics (since the block
is really a function), pcall affects tracebacks a bit (e.g. you
instead need xpcall to forward the error handler, errorlevel isn't
preserved, etc.), and there may be some performance implications.
Still, it's do-able, and this could be an acceptable reason against
decision #1.