From: Tanaka Akira Date: 2011-08-03T23:03:09+09:00 Subject: [ruby-core:38745] Re: [Ruby 1.9 - Bug #5138][Open] Add nonblocking IO that does not use exceptions for EOF and EWOULDBLOCK 2011/8/2 Yehuda Katz : > The current Ruby I/O classes have non-blocking methods (read_nonblock and write_nonblock). These methods will never block, and if they would block, they raise an exception instead (IO::WaitReadable or IO::WaitWritable). In addition, if the IO is at EOF, they raise an EOFError. > > These exceptions are raised repeatedly in virtually every use of the non-blocking methods. This patch adds a pair of methods (try_read_nonblock and try_write_nonblock) that have the same semantics as the existing methods, but they return Symbols instead of raising exceptions for these routine cases: I'm neutral about this proposal. Although the exceptions are not exceptional, they are very educational. People who use *_nonblock immediately find nonblocking I/O is not a simple replacement of blocking I/O. I think IO#read* should raise EOFError for consistency. (There is an exception, IO#read, though.) -- Tanaka Akira