[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Reading from an empty file
- From: Shmuel Zeigerman <shmuz@...>
- Date: Tue, 05 Sep 2017 18:02:43 +0300
On 05/09/2017 17:17, Roberto Ierusalimschy wrote:
With this logic we would have an infinite loop in the following case as
I wonder why the first read from an empty file returns nil rather
than an empty string.
E.g. fp:read(10) --> nil
If the zero-sized file exists then it can be interpreted as a file
containing an empty string (IMHO).
Yes, that is a valid interpretation. With that interpretation, all
reads after the last character would return an empty string, as there
are infinite empty strings between the last character and the end of
for k in (""):gmatch(".*") do print("-",k) end
But we don't.