[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANNOUNCE] Lua 5.0 (work0)
- From: Peter Shook <pshook@...>
- Date: Wed, 12 Jun 2002 23:08:44 -0400
I particularly like the way the open, close, and error checking baggage are
all wrapped up and tucked away into one function.
No need to add this to the 'io' lib. The user may want to customize it to
make the error messages more verbose, or add another 'for' loop to handle a
list of files like Perl's magical while( <> ).
On Wednesday 12 June 2002 08:18, Roberto wrote:
> I think a good solution would be something like
> function lines (filename)
> local f = assert(io.open(filename, "r"))
> return function ()
> return f:read() or (assert(f:close()) and nil)
> so that we could use it without any other "preparation":
> for line in lines(file) do ... end
> But I'm not sure whether such function belongs to the `io' lib or to
> some extension library.
> -- Roberto