lua-users home
lua-l archive

Re: 5.1 beta and closing files

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


> This means that code like this (from luasocket)
> 
 > a,b,c= h.request{url="http://www.acme.com/index.html",sink=
> ltn12.sink.file(io.stdout)}
> 
> 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.
> 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
 
-- Roberto

AltStyle によって変換されたページ (->オリジナル) /