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=-2.6 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=no 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 3B00D1F4B4 for ; Wed, 16 Sep 2020 21:13:18 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 944E71209E5; Thu, 17 Sep 2020 06:12:43 +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 BF01F1209DA for ; Thu, 17 Sep 2020 06:12:41 +0900 (JST) Received: by filterdrecv-p3iad2-654c59b698-xf95b with SMTP id filterdrecv-p3iad2-654c59b698-xf95b-19-5F627FE8-71 2020-09-16 21:13:12.890672181 +0000 UTC m=+526666.062929952 Received: from herokuapp.com (unknown) by ismtpd0091p1iad2.sendgrid.net (SG) with ESMTP id crt147Y7R3KymI5VlAqeEw for ; Wed, 16 Sep 2020 21:13:12.872 +0000 (UTC) Date: Wed, 16 Sep 2020 21:13:12 +0000 (UTC) From: eregontp@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 75868 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 17171 X-Redmine-Issue-Author: marcandre X-Redmine-Sender: Eregon 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?KippOI8ZHtTweq7XfQzW93937kJ4QNWwSBuHnaMEcr1I068lhABmCKme0u15RF?= =?us-ascii?Q?0pF8FDRATTMd8VsTksAUrOjk2MPu2D=2FbAa=2FDsMG?= =?us-ascii?Q?13ZVeR2BgYKcbdxK97oj2oyJ+wUEu6WKv2YbFhr?= =?us-ascii?Q?Wscf+rk3nLARpzIHitMFQlPZ=2FW9sVdi9p76t2yl?= =?us-ascii?Q?ZG0C0gVI2plv0ehatgP1eg2Fotd3wa4mITjURxM?= =?us-ascii?Q?gq2UCxtxgbyKrvA=2FM=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 100027 Subject: [ruby-core:100027] [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 Eregon (Benoit Daloze). mame (Yusuke Endoh) wrote in #note-3: > I did not introduce `private_constant` with no receiver because I wanted to avoid a new module state (as I recall, matz now dislikes the module state), but I agree that it is redundant. Interesting, is `private` implemented as state on the module? (but then would need to be thread-local when concurrently loading or so) I always thought it's part of the state stored in the frame. Regarding the issue, I agree it would be nice. Maybe we can make an experiment and gather feedback from gems testing against ruby-head? ---------------------------------------- Feature #17171: Why is the visibility of constants not affected by `private`? https://bugs.ruby-lang.org/issues/17171#change-87578 * Author: marcandre (Marc-Andre Lafortune) * Status: Open * 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 ```ruby 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/