From: mame@... Date: 2020-09-15T23:18:26+00:00 Subject: [ruby-core:100018] [Ruby master Feature#17171] Why is the visibility of constants not affected by `private`? Issue #17171 has been updated by mame (Yusuke Endoh). I think your expectation is reasonable. If we change it, we need much work to estimate its compatibility impact carefully and to design a migration path, of course. I proposed and implemented `private_constant` ten years ago. [Feature #2366] was written in Japanese (sorry!), but as far as I see, no one discussed changing `private`, maybe because of compatibility. I did not introduce `private_constant` with no receiver was 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. ---------------------------------------- Feature #17171: Why is the visibility of constants not affected by `private`? https://bugs.ruby-lang.org/issues/17171#change-87571 * 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/ Unsubscribe: