Issue #5138 has been updated by mame (Yusuke Endoh).


Yehuda Katz and Aaron Patterson,

We discussed your slide at the developer meeting (7/21), but
cannot reach agreement.  Please continue to make a discussion.


Here is a discussion summary.
I hope you find it informative to improve your proposal.


* Matz was positive to the feature itself.

* Matz was NOT positive to the name `try_read_nonblock'.

  - Akr suggested a new name convention about IO:
    `read_*' for exception-style methods, and
    `get_*' for non-exception-style methods.

  - Matz prefered `get_nonblock' to `try_read_nonblock'.
    (but he showed no opinion about the convention itself)

* Matz was pondering whether or not to accept a method returning
  either Symbol or String.

  - He suggested Erlang-style API, always returning a two-length
    array whose contains state (Symbol) and data (String).

* Akr was afraid that the code example in the slide was inaccurate.

  - I didn't understand his opinion; please talk with him directly.

-- 
Yusuke Endoh <mame / tsg.ne.jp>
----------------------------------------
Feature #5138: Add nonblocking IO that does not use exceptions for EOF and EWOULDBLOCK
https://bugs.ruby-lang.org/issues/5138#change-28307

Author: wycats (Yehuda Katz)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: 1.9.4


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:

* :read_would_block
* :write_would_block
* :eof

The patch contains updates for IO, StringIO, and OpenSSL. The updates are fully documented and tested.


-- 
http://bugs.ruby-lang.org/