From: Gary Wright Date: 2007-12-13T13:57:36+09:00 Subject: Re: redefineable not operator On Dec 12, 2007, at 9:24 PM, Martin Duerst wrote: > Here is my general understanding from discussions with Matz > and others: > - In general, Symbols are different if they have different > encodings. > - The encodings that Ruby allows internally all have to be > ASCII-based. > - If symbols are only ASCII, different encodings don't matter. > > I think the consequences of this are: > - You can't use EBCDIC (but who cares?) > - You have to be a bit carefuly with non-ASCII identifiers > such as � and friends. But I guess that's good advice > anyway. I still haven't digested all the symbol/encoding interactions but even setting all that aside, the current implementation of Symbol has strange things like: irb(main):002:0> :"+" == :"+(binary)" => true Maybe if the class were called RubySymbol, this would make sense but as a general symbol abstraction is is pretty hard to understand. The situations where two entirely different byte sequences (in the same encoding) become equal Symbols is essentially dependent on the implementation of Ruby you are running. Rubinius seems to actually follow the MRI behavior but I couldn't find any tests in the spec/tree. Not sure what JRuby does, I don't have it installed. I realize that the probability of actually encountering a name clash like this in the 'wild' is pretty rare but it is still a bit odd and certainly unexpected. Gary Wright