lua-users home
lua-l archive

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


Am 02.02.2017 um 16:08 schrieb Viacheslav Usov:
If f is variable holding the IO library's file object, then, to close the file, one needs to say f:close().

Note the reference manual documents only this use, with the colon syntax.

One, however, could also write f.close(). It is a pretty simple error to make, as I just learned from a colleague. What is the effect of that?

The reference manual does not say.

Looking at the implementation, what seems to happen is that the standard output handle gets closed instead! I'd say this is a bug.

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.

- Bernd