On Fri, 7 Jan 2005, Alexander Kellett wrote:

> ditto here. having [0] result in a single character string is going to
> be a huge performance problem no?

My concern is not that it would result in a performance problem, because
if the [] method had been defined like that from the start and it would
have been a performance problem, then something else could have been
defined to get the numeric value of it, and could have been called
#asc(i) or, more fashionably, #codepoint(i).

However, my first concern is that Ruby has been first defined with
String#[](i) returning the codepoint, and so, making it return another
String instead, breaks the already established interface. When the program
doesn't work, performance weights nothing in the balance. Breaking the
interface is the 16-ton weight that crushes every other possible thing we
may say about the change.

Else, I would have mentioned that we already have at least 3 or 4 direct
ways of extracting one character as a 1-length String. I don't know
whether the goal is to provide as many ways to do this as there are
conditional forms in ruby (i counted nine), but as I said above, this is
largely irrelevant compared to the problem of breaking compatibility.

_____________________________________________________________________
Mathieu Bouchard -=- Montr?al QC Canada -=- http://artengine.ca/matju