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-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 2F10F1F4B4 for ; Fri, 2 Apr 2021 19:42:37 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id D1DB3120A42; Sat, 3 Apr 2021 04:41:36 +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 BCED81208D7 for ; Sat, 3 Apr 2021 04:41:33 +0900 (JST) Received: by filterdrecv-p3iad2-7d7c446bd4-znxjr with SMTP id filterdrecv-p3iad2-7d7c446bd4-znxjr-20-606773A6-50 2021-04-02 19:42:30.714421231 +0000 UTC m=+868176.342389789 Received: from herokuapp.com (unknown) by geopod-ismtpd-2-2 (SG) with ESMTP id q41ybewoRESw8xrWCvaIUQ for ; Fri, 02 Apr 2021 19:42:30.663 +0000 (UTC) Date: Fri, 02 Apr 2021 19:42:30 +0000 (UTC) From: lamont@scriptkiddie.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 79233 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 17472 X-Redmine-Issue-Author: naruse X-Redmine-Sender: lamont 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?4Kn0dANS2V8yOnn1ZPtv+=2FZkTLjL6a8xnPqkRegpFAIy3XJOdBtGXjG8N4CGA0?= =?us-ascii?Q?=2F4g4lpLZmUUyOsq9fkI1EwUYU5eL37S72cN3mk8?= =?us-ascii?Q?PJ68h5K8vkcvHW+ntmA7DuL5DWq+9ki4KQ=2FbmeO?= =?us-ascii?Q?MiRrp+p=2Fp0Xa9TsBlw6I9yhPdC6fUfNoyb6hfNG?= =?us-ascii?Q?lA6HRLK6BEqtU1TYkSs6OqjRxaKTnPqHg9+gwwS?= =?us-ascii?Q?BOnToY4ccswVdZSYQ=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 103190 Subject: [ruby-core:103190] [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 lamont (Lamont Granquist). And people should likely recall the reasons for the existence of symbols and strings. Originally strings were very expensive and not deduplicated, but were garbage collected. While symbols were very cheap, deduplicated and frozen and not garbage collected. Over time they've mutated to the point where frozen string literals and symbols look pretty much identical. Given a time machine, they probably should be literally identical such that :foo.equal?("foo".freeze) would be true which would just render symbols syntactic sugar for string literals. I believe some languages don't have any symbol-like datastructures and instead have frozen strings so trying to extend the JSON standard to have symbols is probably the wrong way around to deal with this problem (those languages would not be made better by introducing symbol-like objects, nobody needs them). That is all way too much to do to the language at this point, though, since the backcompat break would be extensive, but features like this would be good to better opt-in to closer to that kind of behavior. ---------------------------------------- Feature #17472: HashWithIndifferentAccess like Hash extension https://bugs.ruby-lang.org/issues/17472#change-91265 * 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. summary of previous discussion: https://github.com/rails/rails/pull/40182#issuecomment-687607812 -- https://bugs.ruby-lang.org/