Hi,

In MRI 1.8.6 pl220, a rather significant (and backward-incompatible)
change was introduced
into convert_type method. It is now uses respond_to? with true
argument (searching for
conversion methods in private methods as well).

I"m trying to understand why it was needed, and was it really needed
that bad to add to 1.8.6 series?

You see, it adds a bit of inconsistency, and it is an incompatible
change. When the built-in convert_type
is now used, it will search in private methods, but when regural Ruby
code is being written, the
standard/canonical way of doing similar things:

if name.respond_to?(:to_str) .....

For example, open-uri does that, and pretty much every other library
out there too.

And suddenly, some objects in some methods would be converted and in
some other methods would not:

class << (priv_str = Object.new)
  private
    def to_str
      "http://google.com"
    end
end

p String.new(priv_str)  # this now works

require 'open-uri'
p open(priv_str)  # this doesn't


The output is not pretty:
"http://google.com"
/opt/ruby186-dev/lib/ruby/1.8/open-uri.rb:32:in `initialize': No such
file or directory - http://google.com (Errno::ENOENT)

I especially like the error message that confuses the hell out of me :)

Is the idea to look into private method really good one? Private
things should remain private to the object,
and used very rarely. They should not be part of public contract of the object.

(Yes, there are very rare occasions when this needs to be broken, like
marshal/serialization, but why conversion?)

Thanks,
  --Vladimir