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=-4.0 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,PLING_QUERY,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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 3C41F1F466 for ; Tue, 14 Jan 2020 06:27:29 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 88B70120A3D; Tue, 14 Jan 2020 15:27:12 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 65E7B120A30 for ; Tue, 14 Jan 2020 15:27:10 +0900 (JST) Received: by filterdrecv-p3mdw1-56c97568b5-bbmbb with SMTP id filterdrecv-p3mdw1-56c97568b5-bbmbb-18-5E1D5F44-12 2020-01-14 06:27:16.229891744 +0000 UTC m=+2439844.866462702 Received: from herokuapp.com (unknown [52.207.231.224]) by ismtpd0116p1mdw1.sendgrid.net (SG) with ESMTP id 5tQn8-_EQoqYF6o7Ril4HA for ; Tue, 14 Jan 2020 06:27:16.099 +0000 (UTC) Date: Tue, 14 Jan 2020 06:27:16 +0000 (UTC) From: mame@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 72498 X-Redmine-Project: ruby-master X-Redmine-Issue-Id: 16486 X-Redmine-Issue-Author: mame X-Redmine-Issue-Assignee: matz X-Redmine-Sender: mame 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?EJh2gqwnyqXtd++xo=2FinyA1V0bXouTB4FkWnzNiKb48Jn=2Fz3QTaDOeUtS2YuNP?= =?us-ascii?Q?GWkFp9XJT47kedAiFAIg527AUk2HhaOm9Wcw1sZ?= =?us-ascii?Q?cqKSOTmusJ4NDWVAJKpFydDfkHiGoERW7MZ9wXw?= =?us-ascii?Q?2blC+rr6=2FqRwdDEnsml=2FTX0A6GA9+ACXo047gwA?= =?us-ascii?Q?NhpOrvsP44Ctn25VPgy+tnRME71YIfIOgvJlc+u?= =?us-ascii?Q?7xwIGSTo3Il+KmYBE=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 96835 Subject: [ruby-core:96835] [Ruby master Bug#16486] Hash.ruby2_keywords?(hash) and Hash.ruby2_keywords!(hash) 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 #16486 has been updated by mame (Yusuke Endoh). Hi, I talked about this ticket with ko1, nobu, and znz before the dev-meeting. After the discussion, I am still against this. We premise that the ruby2_keywords flag is never a wonderful thing. We want to delete it in the future. `Module#ruby2_keywords` will serve as a mark showing "we need to change this method definition so to accept not only positional rest arguments but also keyword ones explicitly if ruby2_keywords flag is deleted." So, assuming the flag is removed at Ruby 4.0, we'd like users to change their code in the following style: ``` # 2.6 def foo(*args) bar(*args) end ``` ``` # 2.7 .. 4.0 (until ruby2_keywords flag is deprecated) ruby2_keywords def foo(*args) bar(*args) end ``` ``` # 4.0 .. def foo(*args, **kwargs) bar(*args, **kwargs) end # or, if possible def foo(...) bar(...) end ``` If we set `ruby2_keywords` by default, users cannot identify where to fix, and their code will break suddenly after the flag is removed. It would be unacceptable and we will be unable to deprecate `Module#ruby2_keywords` forever. This is not what we want. ---------------------------------------- Bug #16486: Hash.ruby2_keywords?(hash) and Hash.ruby2_keywords!(hash) https://bugs.ruby-lang.org/issues/16486#change-83838 * Author: mame (Yusuke Endoh) * Status: Assigned * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) * Target version: * ruby -v: * Backport: 2.5: DONTNEED, 2.6: DONTNEED, 2.7: REQUIRED ---------------------------------------- Hash's ruby2_keywords flag is designed to be as implicit as possible, but unfortunately, sometimes we need to handle the flag explicitly. In ActiveJob, the whole arguments are serialized and deserialized, and the process removes the flag; in this case, we need to check and save the flag when serializing, and restore the flag when deserializing. https://github.com/rails/rails/pull/38105#discussion_r361863767 It is theoretically possible by [a very hacky code](https://gist.github.com/mame/18cd2dfc7d965d0bad1216f2fdd008ee#file-bouncing_test-patch-L117-L134), but it would be good to provide them officially. https://github.com/ruby/ruby/pull/2818 * `Hash.ruby2_keywords?(hash)` checks if hash is flagged or not. * `Hash.ruby2_keywords!(hash)` flags a given hash. The reason why I don't add them as instance methods (`Hash#ruby2_keywords?`) is that they are never for casual use. The ruby2_keywords flag will be removed after enough migration time. Casual use of them will make it difficult to remove, so I'd like to keep them for non-casual use. (I thought `RubyVM.ruby2_keywords?(hash)` is good but @eregon will be against it :-) @jeremyevans0 Could you tell me your opinion? -- https://bugs.ruby-lang.org/