From: Tanaka Akira Date: 2004-07-23T19:36:58+09:00 Subject: Re: sysread and buffered I/O In article , "daz" writes: > I thought Hal's read_avail (perhaps readavail) was a fair description, but ... > > "readpartial may return data which is not available when readpartial is called" > > Then 'readpartial' is magic ?-) (Returns unavailable data) > I know ... I misunderstand :( readpartial blocks in such case. % (sleep 1; echo abc; sleep 1; echo def) | ./ruby -e 't1 = Time.now; p STDIN.readpartial(4096); t2 = Time.now; p t2-t1' "abc\n" 1.001787 In this case, readpartial blocks because there are no data at first. After 1 second, "abc" is sent over the pipe and readpartial reads and returns it. So, the name read_avail is not accurate. > read_immed ? > (readimmed is *very bad* without the underscore -- weird ! ) > > read_direct ? (probably not good) > > read_instant, readinst, readsnap ? (at this instant in time) How about them, matz? > I think the problem with the name 'readpartial' may be that if *all* > data is available, and 'readpartial' reads it all, then it has "failed" > because it has performed 'read', *not* 'readpartial'. :-> Yes. > 'readchunk' gives too much emphasis to the chunk, IMHO. > readchunk(256) looks too predictable. > If I wanted to read from in chunks, I would try that before > reading the docs. Also, several formats such as PNG defines "chunk" in their spec. -- Tanaka Akira