From: "enduro (Sven Suska)" Date: 2007-05-15T20:49:48+09:00 Subject: Re: Why was the "Symbol is a String"-idea dropped? Hello again, Robert Klemme schrieb: > On 15.05.2007 12:31, enduro (Sven Suska) wrote: > >> Perhaps it is also my programming style: I may use symbols where one >> normally would use strings. > > Yeah, maybe. So where are you using symbols where one normally would > use strings? Let me guess, because I don't know if I am really the only one: 1. Multipurpose-names: Like option-names, used as hash keys but also as names and labels for the corresponding graphics control etc. 2. Logging: Giving a brief hint in the form of a symbol (not the log level), well just because it is easier to type and looks nice >> Not aware? I mean Rails mixes them, right? > > I don't use Rails. :-))) Oops :-), offending agian, am I? :-) :-) >>> Frankly, I believe there is an inherent advantage that you can use >>> symbols vs. strings in code. >>> And I mean not only performance wise but also readability wise. >> >> Readability-wise: precisely what advantage? > > If I see a symbol being used as a Hash key I immediately know (or > rather guess) > that there is only a limited amount of them and they are known > beforehand, > like with options. > > # silly example > opts = { > :length => 12, > :width => 30, > } > # other code > resize( opts[:length] ) Sorry, don't get me wrong: I DID NOT MEAN TO REMOVE the Symbol class. Nor Symbol literals. Thus, your examples would be valid and semantically equivalent code after a "unification" of the classes (regardless if Symbol < String or not). Or I'd better not call it "unification", I don't have a good word, perhaps "joining" would be better. > Don't forget the optical distinction between using 'string', "string" > and :symbol. Also, this won't be affected, see above. >>> [...] on pragmatism and not purity >> >> 1. The core structure must of course be large enough, and a large >> structure may look impure. > > This somehow reminds me of > http://en.wikipedia.org/wiki/G%C3%B6del%27s_incompleteness_theorem ... mystery will always remain ... >> 2. But regarding this particular question: My original notion was >> that keeping >> Symbol and String too separate is not pragmatic. >> (I may change my mind on that, if I read more posts like yours, >> though.) > > Just reread mine a few times - then you don't need the other postings > any more. > That's more efficient - you'll save bandwidth and reading is actually > faster if you know the text already. :-)) Well, as Ruby-users, we don't sacrifice our fun to the god of efficiency, do we... :-) Cheers, Sven