lua-users home
lua-l archive

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


On Thu, Feb 2, 2017 at 4:23 PM, Bernd Eggink <monoped@sudrala.de> wrote:

> Which Lua version are you using? Under 5.3.4 this returns nil and an error message: "cannot close standard file". One could argue about the message, but actually nothing is closed.

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.

Compare that with f.read() or f.write(), which raise a hard error if called without arguments, or when their first argument is not a file.

Cheers,
V.