lua-users home
lua-l archive

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

> When writing:
> local data, err = f()
> what is the error condition, data being nil, or err being not nil?
data being nil or false

> Is returning data AND a error frowned upon? Example: your f() is
> instructed to return data in chunks of N bytes. But when the last chunk
> is being read, the connection (socket, whatever) closes and f has less
> than N bytes. An API that returns "incompletedata, 'closed'" is well
> regarded?

-- You may consider following:
local status, data = assert (f ())
-- or even
local data, status = assert (f ()) -- here data should be "" in case
of "incompletedata" or "closed"