Tanaka Akira wrote:
Hal Fulton writes:
>>>I am not sure I like readchunk. I think I prefer an underscore
>>>at least. Other ideas might be:
>>> read_avail # meaning "available"
>> An underscore is inconsistent with other IO read??? methods: readchar,
>> readline, readlines.
avail: readpartial may return data which is not available when readpartial is called.
> But I do not really care much, readchunk is ok if it works.
Good name is necessary to incorporate a method to ruby.
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
* ios.readpartial(integer [, buffer]) => string, buffer, or nil
* Reads at most <integer> bytes from the I/O stream but
* it blocks only if <ios> has no data immediately available.
* If the optional <buffer> argument is present,
* it must reference a String, which will receive the data.
* It raises <EOFError> on end of file.
* STDIN.readpartial(4096) #=> "Data immediately available"
(readimmed is *very bad* without the underscore -- weird ! )
read_direct ? (probably not good)
read_instant, readinst, readsnap ? (at this instant in time)
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'. :->
'readchunk' gives too much emphasis to the chunk, IMHO.
readchunk(256) looks too predictable.
If I wanted to read from <ios> in chunks, I would try that before
reading the docs.
Users of 'read_avail' or 'read_immed' would, one hopes, want to
refer to the docs before using. I think the docs of *other*
methods could say: "... if you need to reduce the risk of blocking,
'readpartial' may be more appropriate, here".
Errr, sorry to be of no help whatsoever.
Two machine translations of [ruby-dev:23247] (*not* recommended reading
Excite (Japan): ===============================================
sysread thing which takes into consideration the buffer of stdio considered
since before since mind was suitable at last readpartial was mounted.
Demand of wanting to take in the data which has arrived although it does not
know how much data arrival is carried out from the pipe or the socket, if
there are such methods in the settled unit nonblock It can fill without using
sysread. Here, I do not want to use nonblock because nonblock is under a trouble.
Moreover, not wanting to use sysread is everything but IO. (the buffer of stdio
is treated) It is because it becomes impossible to use a method. nonblock is
avoidable, permitting using other methods of IO, if there is readpartial.
attaching dividing and coming out and saying [ to say ] like this
Finally, because the air faced, it tried mounting the sysread thing readpartial
which you thought from the time before, considers the buffer of stdio.
When there is such method, you do not understand about some data it has arrived
from the pipe and the socket, but it is, the data is to take in at the large
unit to be, with the request which is said without using nonblock and sysread,
it is possible to fill up. Therefore here, as for we would not like to using
nonblock, as for nonblock the origin of trouble is. In addition, because we
would not like to using sysread handles the buffer of other (stdio of IO)
becomes unable to use method is. If there is readpartial, while allowing the fact
that the other method of IO is used, it can avoid nonblock. With being the case
that it is said, the fact that you attach such how probably will be?