[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Reference doubts (2)
- From: Enrico Colombini <erix@...>
- Date: Wed, 3 Mar 2004 17:23:57 +0100
On Wednesday 03 March 2004 13:46, Roberto Ierusalimschy wrote:
[regarding file.close() calling an error on failure]
> Are you sure?
Here is what I mean:
Lua 5.0 Copyright (C) 1994-2003 Tecgraf, PUC-Rio
> f = io.open("test.test", "w")
> print(f)
file (0x80770c0)
> r = io.close(f) -- or: r = f:close()
> print(r)
true
> print(f)
file (closed)
> r = io.close(f)
stdin:1: attempt to use a closed file
stack traceback:
[C]: in function `close'
stdin:1: in main chunk
[C]: ?
Perhaps "on failure" refers only to the underlying fclose() failing,
not to the case of calling io.close() with an already closed file?
(I didn't try other file functions in the same situation)
Enrico