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.

I think f.close() should result in an error just like it does with f.read() and the other file functions.

Cheers,
V.
Hi Viacheslav,

f:close() is syntax candy for f.close(f)

--
Oliver