From: Kornelius Kalnbach Date: 2006-11-08T03:01:41+09:00 Subject: Re: No more Symbol < String? David wrote: > Is "bikeshed" shorthand for "unimportant"? :-) No, it should mean: "Low-Tech Discussion on Ruby, please accelerate". It was the first bikeshed example in matz' keynote for RubyConf 2006. But my mail client seems to think that this is spam (wanna buy a b1ke5hed?), so my prefix idea (like [TINY] for Rails patches) may be bad. I removed it. Back to topic. matz wrote: > Even though it is highly against DuckTyping, people tend to use case > on classes, and Symbol < String often cause serious problems. I found > several of these even in the standard distribution libraries. Yes, I also used "case String" in one of my libraries. The Ruby 1.8 and 1.9 compatible fix was very simple: "instance_of?". I don't have to change that now. It still seems to be a very reliable solution. And Duck Typing won't help: Both String and Symbol respond_to :to_str, even now. I don't ask to remove Symbol#to_str, it seems justified, but it also means that String and Symbol quack the same melody. After thinking about it, I really like the idea of "automagically" created Symbols by freezing Strings. We have Fixnum<>Bignum behind the scenes (which is only for performance and memory reasons AFAIK), and the Symbol<>String problem is alike. When I use Symbols, I care about five things, ordered by importance: - easy writing (:bla) - they save their textual value somehow (for to_s and inspect) - they are distinguishable from Strings in some easy and obvious way - they save memory (singletons) - performance (comparison and hashing are fast) As a programmer, I don't care about: - how they are represented internally - the value of object_id (never used it!) - whether they are mutable or frozen - how Sring and Symbol are related in the class hierarchy That's just my opinion. The Symbol <=> String issue seems to be a matter of how people are using them in 1.8. So, your idea of looking at stdlibs is very good, I think. The current solution works for me. I'm sure we will find the best way. [murphy]