lua-users home
lua-l archive

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




On 10/17/06, Rici Lake <lua@ricilake.net> wrote:



Speaking of EPERM and friends, I'm of the opinion that "posix-like"
error codes should be returned as strings ("EPERM") rather than
whatever number happens to be the value of EPERM on the particular os.
The strings are a lot easier to deal with in script code, and there's
no point I can see to defining errno.EPERM as some number rather than
just having the API return "EPERM".


I completly agree.  I find myself more often then not using strerr or perror to print the error code in a user readable form then I ever do actually checking what errno actually is.  There are cases when you have to do this to recover from an 'expected' error yes, but in lualand its easy enough to say: "if err == 'eperm'" then ... end and it is less annoying to say io.write(err) then it is to do io.write(foo.strerr(err))...  That combined with the lua convention to return nil followed by the error when a function fails makes it un-necessary to even worry about having an errno variable floating around at all...  Oh, and it makes assert work like it should.  Which is grand.

Mike