From: matz@... (Yukihiro Matsumoto) Date: 2004-04-05T16:13:41+09:00 Subject: to_str (Re: deciding between ruby and python) Hi, In message "Re: deciding between ruby and python" on 04/04/05, Dave Benjamin writes: |I'd really like to understand what you mean, here. In your first sentence, |did you mean to say "I expect the object to be a duck *that* quacks like |strings?" If so, what does it mean to quack like a string? If not, what were |you really trying to say? Suppose you understand "duck typing". Defining "to_str" is a way to make an object to behave like string _argument_. Some C defined built in methods require String structure inside. This is against duck typing principle, but need to be so for performance. Those methods call "to_str" before processing string arguments, as work around. When you want to implement an object that behave exactly like strings, you need to define "to_str" method that returns string representation (i.e. one with String structure) along with other methods in String class. In summary, "to_str" should always be part of string method set (since it's a performance hack). Emphasizing "to_str" alone too much is not encouraged. matz.