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.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, 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 F36421F934 for ; Mon, 26 Oct 2020 07:52:24 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 5AEB5120A5A; Mon, 26 Oct 2020 16:51:45 +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 9B72D120A58 for ; Mon, 26 Oct 2020 16:51:43 +0900 (JST) Received: by filterdrecv-p3iad2-64988c98cc-gzbc7 with SMTP id filterdrecv-p3iad2-64988c98cc-gzbc7-19-5F968034-34 2020-10-26 07:52:20.503616484 +0000 UTC m=+212248.576006199 Received: from herokuapp.com (unknown) by geopod-ismtpd-1-6 (SG) with ESMTP id JjI-z27AR8C-fMqUrAfBHQ for ; Mon, 26 Oct 2020 07:52:20.464 +0000 (UTC) Date: Mon, 26 Oct 2020 07:52:20 +0000 (UTC) From: matz@ruby.or.jp Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 76433 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 17171 X-Redmine-Issue-Author: marcandre X-Redmine-Sender: matz 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?bXEIHGfdFwsIlBTndiToCp=2Fmc2rfxRD2sZAksRKJIHXxd3tzcdHKoBvEV7OY3M?= =?us-ascii?Q?6ZZ2NS5yvcPIoeutYwk6BOr+iLmp0Cr+qHc8yOP?= =?us-ascii?Q?dozkMetmxxoMNB3FUEu2V93blw2=2FOWnMD5=2FbNNi?= =?us-ascii?Q?hHVVnd=2FaP4yHO4r4jjWmcMqfJiscdq0Bz44jaAi?= =?us-ascii?Q?TzDf8jdu3BwE0ionHY0f7abnhqLFOq7NKlwGd70?= =?us-ascii?Q?0N7iZHiscm40K4HnA=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 100561 Subject: [ruby-core:100561] [Ruby master Feature#17171] Why is the visibility of constants not affected by `private`? 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 #17171 has been updated by matz (Yukihiro Matsumoto). Status changed from Open to Rejected This looks very interesting, but it would introduce quite big incompatibility. I don't want to break existing code. Matz. ---------------------------------------- Feature #17171: Why is the visibility of constants not affected by `private`? https://bugs.ruby-lang.org/issues/17171#change-88191 * Author: marcandre (Marc-Andre Lafortune) * Status: Rejected * Priority: Normal ---------------------------------------- ```ruby class Foo def call_me # ... end private SOME_DATA = %i[...].freeze # is public, why not private? def calc_stuff # is private, ok. # ... end end ``` It's probably a naive question, but why shouldn't `SOME_DATA`'s visibility be private? When writing gems, more often than not the constants that I write are not meant for public consumption. I find it redundant (and tiresome) to explicitly write `private_constant :SOME_DATA`. -- https://bugs.ruby-lang.org/