https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112015-12-29T08:31:13ZRuby Issue Tracking SystemRuby master - Feature #11919: Passing a module directly https://bugs.ruby-lang.org/issues/11919?journal_id=558392015-12-29T08:31:13Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/55839/diff?detail_id=39863">diff</a>)</li><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul><p>You can write it as</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">using</span> <span class="no">Module</span><span class="p">.</span><span class="nf">new</span> <span class="p">{</span>
<span class="n">refine</span> <span class="o">...</span>
<span class="o">...</span>
<span class="p">}</span>
</code></pre>
<p>Or without <code>Module.new</code>?</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">using</span> <span class="k">do</span>
<span class="n">refine</span> <span class="o">...</span>
<span class="o">...</span>
<span class="k">end</span>
</code></pre> Ruby master - Feature #11919: Passing a module directly https://bugs.ruby-lang.org/issues/11919?journal_id=558402015-12-29T09:04:13Zsawa (Tsuyoshi Sawada)
<ul></ul><p>Nobuyoshi Nakada wrote:</p>
<blockquote>
<p>You can write it as</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">using</span> <span class="no">Module</span><span class="p">.</span><span class="nf">new</span> <span class="p">{</span>
<span class="n">refine</span> <span class="o">...</span>
<span class="o">...</span>
<span class="p">}</span>
</code></pre>
</blockquote>
<p>Right. I had forgotten about operator precedence. My example did not make sense.</p>
<blockquote>
<p>Or without <code>Module.new</code>?</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">using</span> <span class="k">do</span>
<span class="n">refine</span> <span class="o">...</span>
<span class="o">...</span>
<span class="k">end</span>
</code></pre>
</blockquote>
<p>I think this is what I actually wanted to ask for.</p> Ruby master - Feature #11919: Passing a module directly https://bugs.ruby-lang.org/issues/11919?journal_id=943692021-10-27T23:16:25Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul></ul><p>I think this feature would be useful, and submitted a pull request to implement it: <a href="https://github.com/ruby/ruby/pull/5039" class="external">https://github.com/ruby/ruby/pull/5039</a></p> Ruby master - Feature #11919: Passing a module directly https://bugs.ruby-lang.org/issues/11919?journal_id=943772021-10-28T11:02:09ZEregon (Benoit Daloze)
<ul></ul><p>I'm rather neutral about this.<br>
On one hand, I think <code>using Module.new {</code> is clearer that there is a module involved and might avoid some confusion when learning about refinements,<br>
OTOH it seems a fairly harmless shorthand which doesn't do too much magic.</p> Ruby master - Feature #11919: Passing a module directly https://bugs.ruby-lang.org/issues/11919?journal_id=943782021-10-28T11:07:12Zzverok (Victor Shepelev)zverok.offline@gmail.com
<ul></ul><p>Discussed here, also: <a class="issue tracker-2 status-1 priority-4 priority-default" title="Feature: Shorter syntax for anonymous refinements (Open)" href="https://bugs.ruby-lang.org/issues/16241">#16241</a></p>
<p>Copying my comment from there:</p>
<blockquote>
<p>I believe that is really a super-good thing. As I've written elsewhere in this tracker, the most useful case for refinements is "in the current module, I want some shortcuts for my code to look cleaner". For example, <a href="https://github.com/zverok/drosterize" class="external">here</a> and <a href="https://github.com/zverok/xkcdize" class="external">here</a> I experimented with representing some graphics algorithms in a most "readable" way, adding really small methods to the core (Numeric) and RMagick objects. The point is "here, in this module, I crave for some things to exist in some objects".</p>
</blockquote>
<blockquote>
<p>So, "inplace refinements" is probably the main kind of refinements the developer could care about; while "refinements in a module" could be used, probably, for some "more hygienic" ActiveSupport-alike gems, or some specific blends of Ruby (like <code>using Geometry</code> with a ton of specific geometry-related services added to numbers and matrices and whatnot).</p>
</blockquote> Ruby master - Feature #11919: Passing a module directly https://bugs.ruby-lang.org/issues/11919?journal_id=943802021-10-28T11:13:24ZEregon (Benoit Daloze)
<ul><li><strong>Related to</strong> <i><a class="issue tracker-2 status-1 priority-4 priority-default" href="/issues/16241">Feature #16241</a>: Shorter syntax for anonymous refinements</i> added</li></ul> Ruby master - Feature #11919: Passing a module directly https://bugs.ruby-lang.org/issues/11919?journal_id=943822021-10-28T11:14:15ZEregon (Benoit Daloze)
<ul><li><strong>Related to</strong> <i><a class="issue tracker-2 status-6 priority-4 priority-default closed" href="/issues/14344">Feature #14344</a>: refine at class level</i> added</li></ul> Ruby master - Feature #11919: Passing a module directly https://bugs.ruby-lang.org/issues/11919?journal_id=943842021-10-28T11:15:31ZEregon (Benoit Daloze)
<ul></ul><p>I guess we need to persuade matz then: <a href="https://bugs.ruby-lang.org/issues/14344#note-15" class="external">https://bugs.ruby-lang.org/issues/14344#note-15</a> (<a href="https://bugs.ruby-lang.org/issues/16241#note-5" class="external">https://bugs.ruby-lang.org/issues/16241#note-5</a> has some more context)</p> Ruby master - Feature #11919: Passing a module directly https://bugs.ruby-lang.org/issues/11919?journal_id=943942021-10-28T14:43:19Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Rejected</i></li></ul><p>Eregon (Benoit Daloze) wrote in <a href="#note-8">#note-8</a>:</p>
<blockquote>
<p>I guess we need to persuade matz then: <a href="https://bugs.ruby-lang.org/issues/14344#note-15" class="external">https://bugs.ruby-lang.org/issues/14344#note-15</a> (<a href="https://bugs.ruby-lang.org/issues/16241#note-5" class="external">https://bugs.ruby-lang.org/issues/16241#note-5</a> has some more context)</p>
</blockquote>
<p>This shows why we need feature triaging. Otherwise developers who are trying to contribute end up working on things that have already been rejected. I'll reject this and close the related pull request.</p> Ruby master - Feature #11919: Passing a module directly https://bugs.ruby-lang.org/issues/11919?journal_id=943962021-10-28T15:01:53Zsawa (Tsuyoshi Sawada)
<ul></ul><p>jeremyevans0 thanks for taking up the issue, anyway.</p> Ruby master - Feature #11919: Passing a module directly https://bugs.ruby-lang.org/issues/11919?journal_id=944032021-10-29T13:02:23ZDan0042 (Daniel DeLorme)
<ul></ul><p><a class="user active user-mention" href="https://bugs.ruby-lang.org/users/1604">@jeremyevans0 (Jeremy Evans)</a> may I ask why you closed this? Matz has not rejected this idea. He only rejected <code>refine X do</code> (<a class="issue tracker-2 status-6 priority-4 priority-default closed" title="Feature: refine at class level (Rejected)" href="https://bugs.ruby-lang.org/issues/14344">#14344</a>) because <code>refine</code> should not have such different behavior for class vs module. Although there's also <code>refining X do</code> (<a class="issue tracker-2 status-1 priority-4 priority-default" title="Feature: Shorter syntax for anonymous refinements (Open)" href="https://bugs.ruby-lang.org/issues/16241">#16241</a>) which may be a better choice since it has Matz' pre-approval.</p> Ruby master - Feature #11919: Passing a module directly https://bugs.ruby-lang.org/issues/11919?journal_id=944052021-10-29T14:27:25Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul></ul><p>Dan0042 (Daniel DeLorme) wrote in <a href="#note-11">#note-11</a>:</p>
<blockquote>
<p><a class="user active user-mention" href="https://bugs.ruby-lang.org/users/1604">@jeremyevans0 (Jeremy Evans)</a> may I ask why you closed this? Matz has not rejected this idea. He only rejected <code>refine X do</code> (<a class="issue tracker-2 status-6 priority-4 priority-default closed" title="Feature: refine at class level (Rejected)" href="https://bugs.ruby-lang.org/issues/14344">#14344</a>) because <code>refine</code> should not have such different behavior for class vs module.</p>
</blockquote>
<p><a class="user active user-mention" href="https://bugs.ruby-lang.org/users/13">@matz (Yukihiro Matsumoto)</a> pretty much rejected <code>using do</code> as well (<a href="https://bugs.ruby-lang.org/issues/14344#note-15" class="external">https://bugs.ruby-lang.org/issues/14344#note-15</a>): <code>the modified syntax using do is also confusing</code>. So that's why I closed this (this feature is for <code>using do</code>).</p>
<blockquote>
<p>Although there's also <code>refining X do</code> (<a class="issue tracker-2 status-1 priority-4 priority-default" title="Feature: Shorter syntax for anonymous refinements (Open)" href="https://bugs.ruby-lang.org/issues/16241">#16241</a>) which may be a better choice since it has Matz' pre-approval.</p>
</blockquote>
<p>Not sure where you are seeing pre-approval by <a class="user active user-mention" href="https://bugs.ruby-lang.org/users/13">@matz (Yukihiro Matsumoto)</a> in <a class="issue tracker-2 status-1 priority-4 priority-default" title="Feature: Shorter syntax for anonymous refinements (Open)" href="https://bugs.ruby-lang.org/issues/16241">#16241</a>. I guess in the description it says that <a class="user active user-mention" href="https://bugs.ruby-lang.org/users/13">@matz (Yukihiro Matsumoto)</a> indicated <code>refining</code> seems like a better name than <code>using_refined</code>, but that doesn't sound like pre-approval to me. <a class="issue tracker-2 status-1 priority-4 priority-default" title="Feature: Shorter syntax for anonymous refinements (Open)" href="https://bugs.ruby-lang.org/issues/16241">#16241</a> hasn't been rejected yet, though. Personally, I'm not in favor of adding another method for this, so I wouldn't submit a pull request to implement that.</p> Ruby master - Feature #11919: Passing a module directly https://bugs.ruby-lang.org/issues/11919?journal_id=944062021-10-29T16:08:42ZDan0042 (Daniel DeLorme)
<ul></ul><p>jeremyevans0 (Jeremy Evans) wrote in <a href="#note-12">#note-12</a>:</p>
<blockquote>
<p><a class="user active user-mention" href="https://bugs.ruby-lang.org/users/13">@matz (Yukihiro Matsumoto)</a> pretty much rejected <code>using do</code> as well (<a href="https://bugs.ruby-lang.org/issues/14344#note-15" class="external">https://bugs.ruby-lang.org/issues/14344#note-15</a>): <code>the modified syntax using do is also confusing</code>. So that's why I closed this (this feature is for <code>using do</code>).</p>
</blockquote>
<p>Ah yes, I don't see how I missed that. Sorry for the noise.</p>
<blockquote>
<p>Not sure where you are seeing pre-approval by <a class="user active user-mention" href="https://bugs.ruby-lang.org/users/13">@matz (Yukihiro Matsumoto)</a> in <a class="issue tracker-2 status-1 priority-4 priority-default" title="Feature: Shorter syntax for anonymous refinements (Open)" href="https://bugs.ruby-lang.org/issues/16241">#16241</a>.</p>
</blockquote>
<p>Right, "pre-approval" was the wrong word. I meant it as "preliminary" or tentative endorsement, not as "it's already approved".</p>