From: "shevegen (markus heiler)" Date: 2013-02-07T23:40:52+09:00 Subject: [ruby-core:51986] [ruby-trunk - Feature #7797] Hash should be renamed to StrictHash and a new Hash should be created to behave like AS HashWithIndifferentAccess Issue #7797 has been updated by shevegen (markus heiler). > Since #7792 has been rejected (although I don't really understand the > reason except people being afraid of changing I guess) Several reasons were given to you. I do not understand why you try to "summarize" them all by stating that "people are afraid of change". Symbols and Strings are not the same internally. If ruby would get rid of symbols, the language would be simnpler for newcomers. But why have symbols been exposed at the ruby-language level at all? That's right, because they are simply more efficient than Strings. And that has nothing to do with anyone being afraid of change. What you basically tried in your earlier proposal was to change ruby to a completely different language, where Symbols would be gone. This is a huge conceptual change, an undertaking that would even interfere with major release versions. It would break old ruby code for only marginal gains. How could you state that people are "afraid of change" and this is the sole reason for the rejection of your proposal? > h = {a: 1, 'a' => 2} This would only confuse people. Yes, this crap would confuse people. I myself use the old syntax, and it is also the one ruby uses internally. You can see this by pasting the hash there into IRB - you will see that a: 1 will become :a => 1. I myself would rather like if this new syntax would not have been added at all. I dont like it, and even though you save a few keys, I think it adds more to confusion rather than make things really better. I do agree with you that it is annoying that symbols and strings can be used for hash keys. When I write ruby code, I always have to ask myself whether I want to use a symbol or a string as key. I do not however see how your proposal makes THIS very decision any simpler. ---------------------------------------- Feature #7797: Hash should be renamed to StrictHash and a new Hash should be created to behave like AS HashWithIndifferentAccess https://bugs.ruby-lang.org/issues/7797#change-35993 Author: rosenfeld (Rodrigo Rosenfeld Rosas) Status: Open Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: Next Major Since #7792 has been rejected (although I don't really understand the reason except people being afraid of changing I guess) I'd like to propose an alternative solution to most of the problems caused by the differences between symbols and strings. From my previous experience, most of the time I'm accessing a hash, I'd prefer that it behaved like HashWithIndifferentAccess (HWIA from now) from active_support gem. Transforming all possible hashes in some object to HWIA is not only boring to do code but also time consuming. Instead, I propose that {}.class == Hash, with Hash being implemented as HWIA and the current Hash implementation renamed to StrictHash. That way, this should work: a = {a: 1, 'b' => 2} a[:a] == a['a'] && a['b'] == a[:b] I don't really see any real use case where people really want to have a hash like this: h = {a: 1, 'a' => 2} This would only confuse people. It also avoids confusion when parsing/unparsing from popular serialization formats, like JSON: currently: h = {a: 1} j = JSON.unparse h h2 = JSON.parse j h[:a] != h2[:a] With the new proposition (I'm assuming JSON should use Hash instead of StrictHash when parsing) h[:a] == h2[:a]. This is just a small example but most real-world usage for hashes would benefit from regular hashes behaving like HWIA. -- http://bugs.ruby-lang.org/