lua-users home
lua-l archive

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


On Friday, January 16, 2015 01:11:05 AM Rena wrote:
> 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.

That's what nil,message is, essentially. A function that may fail returns a 
virtual "Maybe" type that is defined as '(nil-or-false,message)|(not-
falsey,...)' except some functions have to use explicit nil or false because 
the other has to be in the set of valid values. But that's why adding a new 
Error type or having an out-of-band error flag (ala C errno) doesn't improve 
the language because it's only rearranging where and how the error is stored 
without changing the logical way that it is raised or caught.

-- 
tom <telliamed@whoopdedo.org>