From: Eric Wong Date: 2013-07-10T09:03:19+09:00 Subject: [ruby-core:55890] Re: [ruby-trunk - Feature #5138] Add nonblocking IO that does not use exceptions for EOF and EWOULDBLOCK "tenderlovemaking (Aaron Patterson)" wrote: > As for Erlang style return values. It seems interesting, but that > means every call to `try_read_nonblock` would allocate an array. The > only possible return values would be: I prefer to avoid the requirement for allocating _anything_ in the common case. So "no" to the tuple retvals. How about making the destination buffer a required argument, and returning: Integer - length in bytes on successful read Symbol - :wait_readable/:wait_writable (common) nil - EOF case ret = io.try_read(maxlen, buffer) when Integer process_buffer(buffer, ret) when nil break when Symbol io.__send__(ret, timeout_sec) # :wait_readable,:wait_writable end while true I think making the buffer a required argument makes sense anyways for performance (not just GC, but keeping the CPU cache hot regardless of VM/language, too).