https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112019-12-21T14:01:12ZRuby Issue Tracking SystemRuby master - Feature #16441: Enumerable#take_while_afterhttps://bugs.ruby-lang.org/issues/16441?journal_id=833092019-12-21T14:01:12Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>Flip-flop is the winner!!!</p> Ruby master - Feature #16441: Enumerable#take_while_afterhttps://bugs.ruby-lang.org/issues/16441?journal_id=833142019-12-21T16:12:50Zshevegen (Robert A. Heiler)shevegen@gmail.com
<ul></ul><p>This is of course only my personal opinion, but I believe that long<br>
names can be somewhat problematic. Now I myself use really very<br>
long method names, but for ruby as a "basic building block" (that<br>
is the core parts), I think the shorter the method name, the better<br>
(usually that is).</p>
<p>So we have methods such as:</p>
<pre><code>.size
.keys
.uniq
</code></pre>
<p>Short and expressive.</p>
<p>And we have some methods with two words:</p>
<pre><code>.each_pair
.take_while
</code></pre>
<p>And so forth.</p>
<p>I believe that the net benefit of methods becomes lesser the more words<br>
have to be used for a particular method call - which I mean in general,<br>
primarily, not solely confined to the name/issue here. Like, three<br>
words, or four words, or five words ... or things such as<br>
HashWithIndirectAccess.</p>
<p>I think three words are quite unwieldy. It also feels a bit strange since<br>
this is almost as if you could do a method-chain, like:</p>
<pre><code>.take_while_after
.take.while.after
</code></pre>
<p>Reminds me a bit of rspec.</p>
<p>Of course it depends a lot on how someone uses ruby, which "style" is to<br>
be preferred, but for me personally, I much prefer the shorter, simpler<br>
variant whenever that would be possible. It is a bit comparable to<br>
"yield_self" versus "then" - if the question is solely between these two<br>
names, then the name "then" is IMO better, because it is easier to use.</p>
<p>I don't have a good alternative name either, but I am also not sure if there<br>
can be a much simpler name IF the thought behind the suggestion is to<br>
combine so many different method calls in one go.</p>
<p>Perhaps we could have two variants of ruby, one for the simple minds, and<br>
one for the uber gurus that may find haskell too easy. ;-)</p>
<blockquote>
<p>The idea is the same as with flip-flops .. vs ...</p>
</blockquote>
<p>Well, the difference here is a single (!) character.</p>
<p>I think you are a bit afar from that difference. I also already find<br>
.take_while a peculiar name ...</p>
<p>By the way, another small point to note is that in the method chain,<br>
"while" appears twice. That seems a bit odd to me too.</p> Ruby master - Feature #16441: Enumerable#take_while_afterhttps://bugs.ruby-lang.org/issues/16441?journal_id=833232019-12-22T05:08:55Zsawa (Tsuyoshi Sawada)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/83323/diff?detail_id=55894">diff</a>)</li></ul> Ruby master - Feature #16441: Enumerable#take_while_afterhttps://bugs.ruby-lang.org/issues/16441?journal_id=834372019-12-26T22:32:07ZDan0042 (Daniel DeLorme)
<ul></ul><p><code>take_while_after</code> is rather unwieldy, so in terms of naming maybe I can suggest:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">str</span><span class="p">.</span><span class="nf">each_line</span><span class="p">(</span><span class="ss">chomp: </span><span class="kp">true</span><span class="p">).</span><span class="nf">take_from</span><span class="p">{</span> <span class="n">_1</span> <span class="o">==</span> <span class="s1">'<<'</span> <span class="p">}.</span><span class="nf">take_upto</span><span class="p">{</span> <span class="n">_1</span> <span class="o">==</span> <span class="s1">'>>'</span> <span class="p">}</span>
</code></pre> Ruby master - Feature #16441: Enumerable#take_while_afterhttps://bugs.ruby-lang.org/issues/16441?journal_id=834382019-12-26T23:13:29Zsawa (Tsuyoshi Sawada)
<ul></ul><p>Dan0042 (Daniel DeLorme) wrote:</p>
<blockquote>
<p><code>take_while_after</code> is rather unwieldy, so in terms of naming maybe I can suggest:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">str</span><span class="p">.</span><span class="nf">each_line</span><span class="p">(</span><span class="ss">chomp: </span><span class="kp">true</span><span class="p">).</span><span class="nf">take_from</span><span class="p">{</span> <span class="n">_1</span> <span class="o">==</span> <span class="s1">'<<'</span> <span class="p">}.</span><span class="nf">take_upto</span><span class="p">{</span> <span class="n">_1</span> <span class="o">==</span> <span class="s1">'>>'</span> <span class="p">}</span>
</code></pre>
</blockquote>
<p>Such methods are the same as the cases 6 and 7 in my proposal <a class="issue tracker-2 status-6 priority-4 priority-default closed" title="Feature: Enumerable#take_*, Enumerable#drop_* counterparts with positive conditions (Rejected)" href="https://bugs.ruby-lang.org/issues/16446">#16446</a>.</p> Ruby master - Feature #16441: Enumerable#take_while_afterhttps://bugs.ruby-lang.org/issues/16441?journal_id=838302020-01-14T03:24:19Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul></ul><p><a class="user active user-mention" href="https://bugs.ruby-lang.org/users/271">@akr (Akira Tanaka)</a> What do you think?</p> Ruby master - Feature #16441: Enumerable#take_while_afterhttps://bugs.ruby-lang.org/issues/16441?journal_id=838352020-01-14T05:05:28Zakr (Akira Tanaka)akr@fsij.org
<ul></ul><p>mame (Yusuke Endoh) wrote:</p>
<blockquote>
<p><a class="user active user-mention" href="https://bugs.ruby-lang.org/users/271">@akr (Akira Tanaka)</a> What do you think?</p>
</blockquote>
<p>I'm neutral with this feature.<br>
I don't like the name, take_while_after, though.</p>
<p>I feel that it's better to consider the method name in wider view, like [Feature <a class="issue tracker-2 status-6 priority-4 priority-default closed" title="Feature: Enumerable#take_*, Enumerable#drop_* counterparts with positive conditions (Rejected)" href="https://bugs.ruby-lang.org/issues/16446">#16446</a>].</p> Ruby master - Feature #16441: Enumerable#take_while_afterhttps://bugs.ruby-lang.org/issues/16441?journal_id=838362020-01-14T05:09:58Zakr (Akira Tanaka)akr@fsij.org
<ul><li><strong>Related to</strong> <i><a class="issue tracker-2 status-6 priority-4 priority-default closed" href="/issues/16446">Feature #16446</a>: Enumerable#take_*, Enumerable#drop_* counterparts with positive conditions</i> added</li></ul> Ruby master - Feature #16441: Enumerable#take_while_afterhttps://bugs.ruby-lang.org/issues/16441?journal_id=839062020-01-16T06:53:11Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Rejected</i></li></ul><p>I don't see the real-world usage of <code>take_while_after</code>. Use <code>take_while</code> with proper condition.</p>
<p>Matz.</p>