lua-users home
lua-l archive

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




On Thu, Sep 26, 2013 at 5:32 AM, Pierre Chapuis <catwell@archlinux.us> wrote:


So I think this makes the code more fragile. I would rather just deal with
numbers and keep erroring out in other cases (maybe not using error() if
you prefer to handle errors differently in your code, e.g. by returning
nil).


I see. I guess I'll just add a special case for numbers and booleans.
I could do what you suggest for functions, and check its return type (and enforce strings, numbers and booleans). 
If it is a userdata, see if it has a __tostring metamethod. But I'm not sure I'm willing to go into that much complexity.

So, basically, I will do what you suggested (and return nil plus error message).