[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Reference doubts (2)
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 03 Mar 2004 09:46:02 -0300
> 1) Does io.output() close the previously default output file (if
> any) or should the latter be closed with io.close() before calling
> io.output() to select another output file?
io.output does not close any file. The program should close the previous
default output file (otherwise the garbage collection will do it, but
maybe too late).
> However, file.close() seems to return true on success, but calls an
> error on failure.
Are you sure?
> 3) In which mode does io.input(filename) open the file? "r" or "w"?
"r" (it's implicit, as it will be an input file). "text mode" means
that it is not in bynary mode.
> 4) Does io.input() return a file object (handle) even when an argument is
> given? It seems so.
Yes. It (and io.output) always returns the current handle (after the
eventual modification).
-- Roberto