lua-users home
lua-l archive

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


Hi,

> I have found it frustrating also that some io and socket functions have
> nil returned on success, some nil on error, some return a message in the
> first value and some in the second, not to mention that execute will do
> "0" on success, etc.

Whenever an  error condition  is detected  in luasocket,  every function
called returns nil instead of its  expected return value, followed by an
error message. When no error  is detected, the functions return whatever
return values they should and the error message that follows is nil.

Your comment  is probably related to  the send function. The  "number of
bytes sent" return value was added in  a recent version. Since there was
formerly no return values, the function only returned the error message.
That's why  it returns nil on  success, meaning there were  no errors to
report.

Maybe I  should return the  "number of bytes  sent" as the  first return
value, followed by  the error code, to make the  API uniform. That would
break compatibility, though.  Anyone has any suggestions  or comments on
the matter? I might do just that in future versions.

Regards,
Diego.