https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112013-04-16T20:02:02ZRuby Issue Tracking SystemRuby master - Feature #8275: Add Module#public_const_gethttps://redmine.ruby-lang.org/issues/8275?journal_id=386122013-04-16T20:02:02Zvipulnsward (Vipul Amler)
<ul></ul><p>=begin</p>
<p>And vice-versa for set too maybe</p>
<p>(({Module#public_const_set}))/<br>
(({Module#private_const_set}))</p>
<p>=end</p> Ruby master - Feature #8275: Add Module#public_const_gethttps://redmine.ruby-lang.org/issues/8275?journal_id=386182013-04-16T23:58:10Zheadius (Charles Nutter)headius@headius.com
<ul></ul><p>What about an optional boolean for the existing const_get/const_set that indicates whether private constants should be included?</p>
<p>I guess having separate methods does align with public_instance_method and friends, though.</p> Ruby master - Feature #8275: Add Module#public_const_gethttps://redmine.ruby-lang.org/issues/8275?journal_id=386312013-04-17T03:02:03Zrkh (Konstantin Haase)me@rkh.im
<ul></ul><p>I was considering a boolean. However, const_get already takes a boolean argument indicating whether or not to include inherited constants, and two boolean arguments would not make a readable API, I guess.</p>
<p>Maybe this would be a good use case for keyword arguments if the API were to be extended?</p>
<p>For instance with the following signature:</p>
<pre><code>const_get(name, inherited = true, private: true)
</code></pre>
<p>Or even overload so that the old signature still works</p>
<pre><code>const_get(name, inherited = true)
</code></pre>
<p>but it might also support</p>
<pre><code>const_get(name, inherited: true, private: true)
</code></pre>
<p>What do you think?</p> Ruby master - Feature #8275: Add Module#public_const_gethttps://redmine.ruby-lang.org/issues/8275?journal_id=386332013-04-17T03:12:29Zheadius (Charles Nutter)headius@headius.com
<ul></ul><p>rkh (Konstantin Haase) wrote:</p>
<blockquote>
<p>I was considering a boolean. However, const_get already takes a boolean argument indicating whether or not to include inherited constants, and two boolean arguments would not make a readable API, I guess.</p>
</blockquote>
<p>Ahh, good point. I agree.</p>
<blockquote>
<p>Maybe this would be a good use case for keyword arguments if the API were to be extended?</p>
<p>For instance with the following signature:</p>
<pre><code>const_get(name, inherited = true, private: true)
</code></pre>
<p>Or even overload so that the old signature still works</p>
<pre><code>const_get(name, inherited = true)
</code></pre>
<p>but it might also support</p>
<pre><code>const_get(name, inherited: true, private: true)
</code></pre>
<p>What do you think?</p>
</blockquote>
<p>Interesting ideas. I'm starting to lean back toward having a separate method rather than pushing too much logic into this one. Keyword args definitely help readability if we wanted to overload, but maybe we really don't need to overload it more than it is overloaded already?</p> Ruby master - Feature #8275: Add Module#public_const_gethttps://redmine.ruby-lang.org/issues/8275?journal_id=955652021-12-23T23:43:56Zhsbt (Hiroshi SHIBATA)hsbt@ruby-lang.org
<ul><li><strong>Project</strong> changed from <i>14</i> to <i>Ruby master</i></li></ul>