[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: f.close() vs f:close()
- From: Peter Aronoff <telemachus@...>
- Date: Thu, 2 Feb 2017 11:18:08 -0500
Viacheslav Usov <email@example.com> wrote:
> The problem is that this does not raise a Lua error. It returns nil and
> the error message just like you say. That can just be ignored silently.
> I think it could also be said that checking f.close() for error returns
> would be unusual anyway.
Maybe this is the problem. I would say that it’s necessary for serious code
to check the return value of *both* open and close. (Both return nil and an
error message in Lua if they fail. Neither returns an error.)
PS See also here re “Dealing with error returns from close()” http://man7.org/linux/man-pages/man2/close.2.html
We have not been faced with the need to satisfy someone else's
requirements, and for this freedom we are grateful.
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System