https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112017-05-19T00:25:11ZRuby Issue Tracking SystemRuby master - Feature #13574: Method redefinition warninghttps://redmine.ruby-lang.org/issues/13574?journal_id=648852017-05-19T00:25:11Zmatthewd (Matthew Draper)matthew@trebex.net
<ul></ul><p>As there's no other way to silence the redefinition warning (apart from removing the method first, which isn't atomic), the fact aliases silence it is very useful.</p>
<p>As a special case, aliasing it back to itself is particularly helpful for this purpose: it avoids polluting the method table with extra names, and is a clear indication we're not actually trying to give the method another name.</p>
<p>I don't know whether it was originally intended to work this way, but I think it is useful enough to keep. I also think a warning is unnecessary because it's not a likely error for a developer to make: there is no similar code that would make more sense.</p> Ruby master - Feature #13574: Method redefinition warninghttps://redmine.ruby-lang.org/issues/13574?journal_id=650852017-05-25T09:32:04ZEregon (Benoit Daloze)
<ul></ul><p>matthewd (Matthew Draper) wrote:</p>
<blockquote>
<p>apart from removing the method first, which isn't atomic</p>
</blockquote>
<p>What do you mean?<br>
That remove_method + new definition is not atomic?</p> Ruby master - Feature #13574: Method redefinition warninghttps://redmine.ruby-lang.org/issues/13574?journal_id=650942017-05-25T17:43:25Zmatthewd (Matthew Draper)matthew@trebex.net
<ul></ul><blockquote>
<p>What do you mean?<br>
That remove_method + new definition is not atomic?</p>
</blockquote>
<p>Yes. Using remove_method + define_method, a concurrent thread may get a NoMethodError. In contrast, using alias_method + define_method, while the other thread could obviously call either the old or new definition (depending on exact timing), there will always be <em>a</em> method there.</p> Ruby master - Feature #13574: Method redefinition warninghttps://redmine.ruby-lang.org/issues/13574?journal_id=809872019-08-25T18:11:06Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Backport</strong> deleted (<del><i>2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN</i></del>)</li><li><strong>Tracker</strong> changed from <i>Bug</i> to <i>Feature</i></li><li><strong>ruby -v</strong> deleted (<del><i>ruby 2.5.0dev (2017-03-22 gc-compact 58059) [x86_64-darwin16]</i></del>)</li></ul>