From: matz@ruby.or.jp
To: ruby-core@ruby-lang.org
Subject: [ruby-core:100561] [Ruby master Feature#17171] Why is the visibility of constants not affected by `private`?
Date: Mon, 26 Oct 2020 07:52:20 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-88191.20201026075220.182@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-17171.20200915203444.182@ruby-lang.org
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/
prev parent reply other threads:[~2020-10-26 7:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-15 20:34 [ruby-core:100016] [Ruby master Feature#17171] Why is the visibility of constants not affected by `private`? marcandre-ruby-core
2020-09-15 21:04 ` [ruby-core:100017] " marcandre-ruby-core
2020-09-15 23:18 ` [ruby-core:100018] " mame
2020-09-16 21:13 ` [ruby-core:100027] " eregontp
2020-09-17 7:36 ` [ruby-core:100029] " jean.boussier
2020-09-29 17:08 ` [ruby-core:100220] " shevegen
2020-10-16 3:55 ` [ruby-core:100414] " marcandre-ruby-core
2020-10-16 4:19 ` [ruby-core:100415] " merch-redmine
2020-10-16 5:26 ` [ruby-core:100416] " marcandre-ruby-core
2020-10-26 7:52 ` matz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-88191.20201026075220.182@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).