https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112012-04-13T17:34:14ZRuby Issue Tracking SystemRuby master - Feature #6287: nested method should only be visible by nesting/enclosing methodhttps://bugs.ruby-lang.org/issues/6287?journal_id=258782012-04-13T17:34:14Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/25878/diff?detail_id=19094">diff</a>)</li></ul><p>I know what you mean, but I think this is a limitation of Ruby's OOP nature. In Ruby, everything belongs to an object. So a method must belong to an object, not another method.</p> Ruby master - Feature #6287: nested method should only be visible by nesting/enclosing methodhttps://bugs.ruby-lang.org/issues/6287?journal_id=258832012-04-13T22:58:49Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/25883/diff?detail_id=19096">diff</a>)</li><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>matz (Yukihiro Matsumoto)</i></li><li><strong>Target version</strong> changed from <i>2.0.0</i> to <i>3.0</i></li></ul><p>Hello,</p>
<p>There is a similar proposal <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Refinements and nested methods (Closed)" href="https://bugs.ruby-lang.org/issues/4085">#4085</a> based on more general idea.</p>
<p>Below is my personal opinion.</p>
<p>Ruby's def statement is not a static definition, but a dynamic<br>
execution that defines a method in the context. This design<br>
allows you to define a method that is defined in some condition:</p>
<p>if windows?<br>
def foo<br>
end<br>
end</p>
<p>, singleton methods for each element in an array:</p>
<p>ary.each do |elem|<br>
def elem.foo<br>
end<br>
end</p>
<p>, and so on.<br>
In the same manner, a "nested" method definition you said:</p>
<p>def define_foo<br>
def foo<br>
end<br>
end</p>
<p>should define a method named "define_foo" that defines a method<br>
named "foo." I think it is consistent.</p>
<p>--<br>
Yusuke Endoh <<a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a></p> Ruby master - Feature #6287: nested method should only be visible by nesting/enclosing methodhttps://bugs.ruby-lang.org/issues/6287?journal_id=258872012-04-14T00:59:15Zcout (Paul Brannan)curlypaul924@gmail.com
<ul></ul><p>On Fri, 2012-04-13 at 22:58 +0900, mame (Yusnuke Endoh) wrote:</p>
<blockquote>
<p>In the same manner, a "nested" method definition you said:</p>
<p>def define_foo<br>
def foo<br>
end<br>
end</p>
<p>should define a method named "define_foo" that defines a method<br>
named "foo." I think it is consistent.</p>
</blockquote>
<p>I agree. The behavior is consistent. But I'm yet to find a case where<br>
this is useful.</p>
<p>Paul</p> Ruby master - Feature #6287: nested method should only be visible by nesting/enclosing methodhttps://bugs.ruby-lang.org/issues/6287?journal_id=352482013-01-07T12:28:45Zshugo (Shugo Maeda)
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li></ul><p>I've implemented all features requested by Matz, so I close this ticket.</p>
<p>The current spec is described at <a href="https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/RefinementsSpec" class="external">https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/RefinementsSpec</a>.</p>
<p>If you have any request for Refinements, please file a new ticket.<br>
However, the feature set of Ruby 2.0.0 has already been frozen, so the spec won't be changed in Ruby 2.0.0 unless otherwise permitted by Matz or Endoh-san.</p>