On Oct 24, 2005, at 7:17 AM, Trans wrote: > Has it ever been considered making String a de-immutablized > subclass of > Symbol? Would this allow for a natural coersion of Symbols to Strings, > akin to Integer to Float? The above is a common enough occurance. And > in general I can't think of a signifficant occurance in which I needed > to distingusih a symbol from a string of the same basic value > (ie. :foo > and 'foo') for the same parameter. I suspect there really is no good > reason to ever do so --b/c if you are, you're doing something rather > tricky that probably should be done another way. Of course if anyone's > got a good counter example please share. > > Not that I've fully work this idea through, but I suppose the upshot > would be two fold: > > 1) Certain method could coerce symbol to string when deemed > appropriate, > such a Hash#[]. This is inappropriate behavior. Attempting to mix strings and symbols for hash keys is bad design. Pick one and stick with it. Rails' HashWithIndifferentAccess has unintuitive behavior, I don't want that unintuitive behavior copied to Ruby. For example, what class are the keys? > 2) If a Symbol doesn't respond to a method then coerce to String and > try that. > (Perhaps certain methods would need to be excluded?) If there are already doubts about its usefulness it is probably a bad idea. I don't want to have devote more brain-space to remembering what classes of objects I send to methods. -- Eric Hodel - drbrain / segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04