lua-users home
lua-l archive

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


On Fri, Jan 16, 2015 at 12:55 AM, William Ahern
<william@25thandclement.com> wrote:
> On Thu, Jan 15, 2015 at 09:54:02PM -0500, Rena wrote:
> <snip>
>> Personally I've sometimes wished Lua had try/catch[1] or some kind of
>> standard error/exception object, because I find the current method a
>> bit awkward:
>> -If you throw an error, then the caller needs to use pcall or xpcall
>> to catch it, which adds overhead (and ugliness with pcalls littered
>> everywhere) and especially is more complicated in C, and can make the
>> execution flow hard to follow.
>
> How do you square the wish for try/catch with your concern for the overhead
> of pcall and the mental burden of tracking non-local jumps? Try/catch syntax
> would just be syntactic sugar atop pcall. And you couldn't benefit from the
> syntax from C code.

Sorry, I should have been clearer: try/catch would just be nicer
syntax for pcall. Returning error objects instead of throwing would
reduce the need to use pcall (or try/catch) and thus the overhead.

-- 
Sent from my Game Boy.