lua-users home
lua-l archive

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


> On Jan 14, 2015, at 12:49 PM, Tom N Harris <telliamed@whoopdedo.org> wrote:
> 
> Then we could stop returning errors as nil,message and just throw exceptions. 
> Another way to encourage this is to have a standard error format that can be 
> reliably caught or re-thrown. The simplest would be to write error messages as 
> "error name: details". Anything else like errors made of two strings, tables, 
> or a new Exception type I think are unnecessarily complicated.
> 
> -- 
> tom <telliamed@whoopdedo.org>
> 

Actually I’d go further and say what’s missing here is a first-class error type. This would naturally solve the nil+message issues since errors could always be distinguished from non-errors with no in-band/out-band ambiguity (which is really the issues here). It would also simplify functions that only return one value, since there is no need to add an auxiliary variable to capture the error message from the second return value. This also naturally fits with exception-based handling as well, though I wont go into how this can be done here.


—Tim