From: "Gerardo Santana Gómez Garrido" Date: 2006-03-25T14:58:17+09:00 Subject: Re: [PATCH] to_str, to_s and StringValue 2006/3/24, Mathieu Bouchard : > On Sat, 25 Mar 2006, Gerardo Santana G�mez Garrido wrote: > > > But while I was at it, I found only 7 references to to_str vs. 34 > > references to to_s. > > Only these objects implement to_str: > > The idea is to distinguish two kinds of conversion: > to_s is for default conversion from some non-String to a String > to_str is for conversion from some would-be-String to a String > > the latter is reserved for classes that are made to be used in place of > Strings, when they need to be converted to true Strings (with nodetype > T_STRING, so that they can be accessed as a character array in C). Oh, I see. Thanks a lot, it's clear now. I should be prepared to handle an exception if I want to use StringValue (because it expects a would-be string, or will fail), otherwise I should use rb_check_string_type and check by myself. If that fails, but I strongly want a string, I should fall back to rb_obj_as_string. Is that correct? -- Gerardo Santana "Between individuals, as between nations, respect for the rights of others is peace" - Don Benito Ju�rez http://santanatechnotes.blogspot.com/