lua-users home
lua-l archive

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


On 14/01/15 16:28, Roberto Ierusalimschy wrote:
So, if the first return is nil, you should be able to safely assume
that there won't be anything of interest after that. Except an
explanation.
You got my point, except about your "except" :-) If the first return is
nil, you should be able to safely assume that there won't be anything of
interest after that. Period.

-- Roberto

Now, how do you imagine these functions:

1. a consumer that is not guaranteed to have data available, like a nonblocking socket. Today it is
    data, err = read()
If data is nil that means that read() could not actually read anything, so can not provide a value. Depending on how read() works, an error message could be useful or not. In the simplest case no error message is needed: no data means no data, do whatever you can.

2. A function that returns a boolean:
    __eq = function (a, b) return a == b  end
There is nothing special in returning a false.

Jorge


[It is weird to be defending an idea in front of it's author.]