lua-users home
lua-l archive

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


I forgot to mention my favorite bugbear in API bindings.

C does not have a true boolean type, so it typically uses 0 and non-zero integers. Given APIs typically either return 0/failure 1/success or 0/success non-zero/error or 0/success -1/look in 'error' for the error or...

That's a pain, and it should not be translated to Lua APIs. Lua provides a clear mechanism for error returns (well, two of them if you include the pcall convention). OS interfaces which simply return the integer result are, in my opinion, un-Lua-like and unnecessarily thin. (And as awkward as the original C interface.)