[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: 5.1 beta and closing files
- From: David Burgess <dburgess@...>
- Date: Tue, 22 Nov 2005 02:21:26 +1100
Thanks Roberto,
I take you points, but I am wondering how to explain to a user
the following (with windows):
> a=)
stdin:1: unexpected symbol near ')'
> io.stderr:close()
> a=)
> io.stderr=io.open("con","wb")
> =io.stderr
file (77C5ACC0)
> a=)
stdin:1: unexpected symbol near ')'
No errors echoed back to the console is interesting
How do you get stderr back on *nix?
On 11/22/05, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> > will close stdout in 5.1 whereas in 5.0.2 it did not.
>
> I may be wrong, but I think a library function should not close a file
> that it did not open.
a) Lua 5.1 did not open stderr or stdout, yet it allows one to close them
b) I was also thinking of user code (non library code)
c) I dont mind so much io.stdout being "closed" (e.g. unavailable), but
I question closing FILE* stdout, STDOUT_FILENO (or their equivalents
in Win32). (also this is less of an issue for the standalone interpreter).
>
>
> > Would it be possible to have [...] an io flag that sets the old behaviour?
>
> -- untested code
> do
> local old_close = io.close
> io.close = function (f)
> f = f or io.output()
> if f == io.stdin or f == io.stdout or f == io.stderr then
> return
> end
> return old_close(f)
> end
> end
I guess it is also a one liner in liolib.c.
DB