From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 657D21F4B4 for ; Sun, 27 Dec 2020 19:09:22 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 4B62F120BB7; Mon, 28 Dec 2020 04:08:33 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 9DF95120BB6 for ; Mon, 28 Dec 2020 04:08:30 +0900 (JST) Received: by filterdrecv-p3mdw1-7474cd8bfd-mjf6h with SMTP id filterdrecv-p3mdw1-7474cd8bfd-mjf6h-19-5FE8DBD7-4 2020-12-27 19:09:11.052278898 +0000 UTC m=+1454812.585805163 Received: from herokuapp.com (unknown) by ismtpd0063p1mdw1.sendgrid.net (SG) with ESMTP id ehVk_OcvRC2ZNNKaGF4iTQ for ; Sun, 27 Dec 2020 19:09:10.960 +0000 (UTC) Date: Sun, 27 Dec 2020 19:09:11 +0000 (UTC) From: daniel@dan42.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 77657 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 17472 X-Redmine-Issue-Author: naruse X-Redmine-Sender: Dan0042 X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?8sy4RigFvRTdBfCVJrT9zb2J88PC92TMQwdNgaWYaq6R2V=2FUzMIxzYpbPuJkhW?= =?us-ascii?Q?81b7JClp8Fq1x3cqPjX0ydAA+tmu1TE0SmabxFl?= =?us-ascii?Q?XGzwhW++yP59NCGhph8p6lZa7CgrP7OYuN3iga0?= =?us-ascii?Q?1Hj+iWtlKLe3WSp+YRS6=2Fj3Y0kbT4BI+kVhJtmW?= =?us-ascii?Q?DiP3r96fB8DJJmYyeSR5zl7twTPqPvlsU8tp6+c?= =?us-ascii?Q?NwRoyGyVyblqXtSrs=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 101755 Subject: [ruby-core:101755] [Ruby master Feature#17472] HashWithIndifferentAccess like Hash extension X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #17472 has been updated by Dan0042 (Daniel DeLorme). I'm also against this, but I think a more general-purpose version might be ok. In my code I use a `NormalizedHash` class which calls `key = normalize(key)` for every method with a `key` argument (as well as `merge`, etc.) I use this base class to define subclasses with specific `normalize` methods; `HeaderHash` converts keys to Http-Header-Camelcase, `OptionsHash` raises an error if the key is not a Symbol. Something that can be used as the basis of different implementations (including `HashWithIndifferentAccess`) might make sense in the stdlib. Might. ---------------------------------------- Feature #17472: HashWithIndifferentAccess like Hash extension https://bugs.ruby-lang.org/issues/17472#change-89582 * Author: naruse (Yui NARUSE) * Status: Open * Priority: Normal * Target version: 3.1 ---------------------------------------- Rails has [ActiveSupport::HashWithIndifferentAccess](https://api.rubyonrails.org/classes/ActiveSupport/HashWithIndifferentAccess.html), which is widely used in Rails to handle Request, Session, ActionView's form construction, ActiveRecord's DB communication, and so on. It receives String or Symbol and normalize them to fetch the value. But it is implemented with Ruby. If we provide C implementation of that, Rails will gain the performance improvement. -- https://bugs.ruby-lang.org/