https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112012-06-30T02:54:12ZRuby Issue Tracking SystemRuby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=275682012-06-30T02:54:12Zyhara (Yutaka HARA)
<ul><li><strong>File</strong> <a href="/attachments/2829">6670.pdf</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/2829/6670.pdf">6670.pdf</a> added</li></ul><p>Adding presentation slide for the feature request meeting (<a href="https://blade.ruby-lang.org/ruby-dev/45708">[ruby-dev:45708]</a>)</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=276692012-07-02T01:41:44Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><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></ul><p>Received. Thank you!</p>
<p>You really want just #last?</p>
<p>--<br>
Yusuke Endoh <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a></p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=276842012-07-02T02:59:28Ztrans (Thomas Sawyer)
<ul></ul><p>While I realize it doesn't exactly fit with the whole iteration thing particularly well, I nonetheless do not think it's unreasonable for Enumerator to support something like #last(n=1). In most cases that just means it has to iterate on down to the end and deliver the result. In some cases it might be able to optimize, say if the enumerable has a fixed size.</p>
<p>This issue might also have some relation to the issue about Enumerable#size, <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Enumerable#size (Closed)" href="https://bugs.ruby-lang.org/issues/6636">#6636</a>.</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=277022012-07-02T12:07:07Zmarcandre (Marc-Andre Lafortune)marcandre-ruby-core@marc-andre.ca
<ul></ul><p>Hi,</p>
<p>trans (Thomas Sawyer) wrote:</p>
<blockquote>
<p>This issue might also have some relation to the issue about Enumerable#size, <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Enumerable#size (Closed)" href="https://bugs.ruby-lang.org/issues/6636">#6636</a>.</p>
</blockquote>
<p>Not directly. Being able to calculate lazily a size does not mean it is easy to have random access, and the api I propose would be quite a bit more complicated if it was to allow for random access.</p>
<p>I feel that the lack of #last is a good thing. It's there to remind you that it might be expensive, and that (for example) it would be worth storing in a local var instead of calling it twice...</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=283952012-07-24T22:53:52Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Assignee</strong> changed from <i>matz (Yukihiro Matsumoto)</i> to <i>yhara (Yutaka HARA)</i></li></ul><p>Yutaka Hara,</p>
<p>I'm happy to inform you that matz has accepted your proposal,<br>
as making #chars, #lines, etc. return an Array (and keep<br>
#each_char, etc as is).</p>
<p>"foo".chars #=> ["f", "o", "o"]<br>
"foo".each_char #=> #<Enumerator: "foo":each_char></p>
<p>Yhara-san, could you create a patch?</p>
<p>--<br>
Yusuke Endoh <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a></p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=286232012-08-03T19:53:39Zyhara (Yutaka HARA)
<ul></ul><blockquote>
<p>I'm happy to inform you that matz has accepted your proposal,<br>
as making #chars, #lines, etc. return an Array (and keep<br>
#each_char, etc as is).</p>
</blockquote>
<p>Thank you. I'm happy too :-)</p>
<p>I will make a patch in this weekend.</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=288932012-08-15T21:30:38Zyhara (Yutaka HARA)
<ul></ul><p>=begin<br>
Hello,</p>
<p>I wrote a patch for String#lines, #chars, #bytes and #codepoints.</p>
<ul>
<li><a href="https://github.com/ruby/ruby/pull/158.diff" class="external">https://github.com/ruby/ruby/pull/158.diff</a></li>
</ul>
<p>Seemingly the following methods also need to be fixed (right?)</p>
<ul>
<li>IO#lines, chars, bytes, codepoints</li>
<li>StringIO#lines, chars, bytes, codepoints</li>
<li>ARGF.lines, chars, bytes
<ul>
<li>Is it intentional that ARGF.codepoints is missing?<br>
=end</li>
</ul>
</li>
</ul> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=316932012-10-27T07:13:17Zko1 (Koichi Sasada)
<ul></ul><p>ping.<br>
status?</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=319102012-10-29T17:43:09Zknu (Akinori MUSHA)knu@ruby-lang.org
<ul></ul><p>If #lines is to become no longer an alias for #each_line, there should be no point in supporting lines {} any more. It should emit a deprecation warning and get unsupported in the future.</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=330752012-11-19T11:59:48Zzzak (zzak _)
<ul><li><strong>File</strong> <a href="/attachments/3267">string_bytes_to_array.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/3267/string_bytes_to_array.patch">string_bytes_to_array.patch</a> added</li><li><strong>Assignee</strong> changed from <i>yhara (Yutaka HARA)</i> to <i>mame (Yusuke Endoh)</i></li></ul><p>I've added Yutaka-san's patch from github, please continue discussion here.</p>
<p>mame, could you please review this?</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=331172012-11-20T03:14:38Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Assignee</strong> changed from <i>mame (Yusuke Endoh)</i> to <i>knu (Akinori MUSHA)</i></li></ul><p>knu, could you please review this? :-)</p>
<p>--<br>
Yusuke Endoh <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a></p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=337362012-11-24T11:16:01Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Assignee</strong> changed from <i>knu (Akinori MUSHA)</i> to <i>nagachika (Tomoyuki Chikanaga)</i></li></ul><p>nagachika-san, could you please review this?</p>
<p>--<br>
Yusuke Endoh <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a></p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=338112012-11-24T19:38:08Zknu (Akinori MUSHA)knu@ruby-lang.org
<ul></ul><p>Sorry, my mail filter was so buggy I failed to be notified.</p>
<p>I've reviewed and already given a comment above, and another on Twitter that yieldp can be dropped in favor of NIL_P(ary), without any of them responded to.<br>
Should I revise the patch myself?</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=338162012-11-24T22:18:00Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul><li><strong>Assignee</strong> changed from <i>nagachika (Tomoyuki Chikanaga)</i> to <i>knu (Akinori MUSHA)</i></li></ul><p>Hello,<br>
Sorry for late reply.</p>
<p>OK, I assign this ticket to knu san again.<br>
Anyway I'm willing to review the patch :)</p>
<p>BTW, I cannot apply string_bytes_to_array.patch on trunk r37835.</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=338172012-11-24T22:24:03Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul></ul><p>Thanks!</p>
<blockquote>
<p>Should I revise the patch myself?</p>
</blockquote>
<p>Could you do it, please?<br>
If you are not willing, please pass the ball to nagachika-san.</p>
<p>--<br>
Yusuke Endoh <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a></p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=338252012-11-25T03:46:19Zknu (Akinori MUSHA)knu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>This issue was solved with changeset r37838.<br>
Yutaka, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<p>String#{lines,chars,codepoints,bytes} now return an array.</p>
<ul>
<li>
<p>string.c (rb_str_each_line, rb_str_lines): String#lines now<br>
returns an array instead of an enumerator. Passing a block is<br>
deprecated but still supported for backwards compatibility.<br>
Based on the patch by yhara. [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: str.chars.last should be possible (Closed)" href="https://bugs.ruby-lang.org/issues/6670">#6670</a>]</p>
</li>
<li>
<p>string.c (rb_str_each_char, rb_str_chars): Ditto for<br>
String#chars.</p>
</li>
<li>
<p>string.c (rb_str_each_codepoint, rb_str_codepoints): Ditto for<br>
String#codepoints.</p>
</li>
<li>
<p>string.c (rb_str_each_byte, rb_str_bytes): Ditto for<br>
String#bytes.</p>
</li>
<li>
<p>NEWS: Add notes for the above changes.</p>
</li>
</ul> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=338632012-11-26T02:23:10Zbrixen (Brian Shirai)brixen@gmail.com
<ul></ul><p>What about IO, StringIO, ARGF as mentioned above?</p>
<p>Thanks,<br>
Brian</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=338732012-11-26T06:01:15Zdrbrain (Eric Hodel)drbrain@segment7.net
<ul></ul><p>=begin<br>
An IO may be infinite (({open "/dev/zero" do |io| io.chars.to_a }})), and so may ARGF ((%ruby -e 'ARGF.chars.to_a' /dev/zero%)).</p>
<p>It doesn't make sense to add it to StringIO, but you make work around the omission through StringIO#string.<br>
=end</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=339812012-11-27T05:36:00Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Assigned</i></li><li><strong>Assignee</strong> changed from <i>knu (Akinori MUSHA)</i> to <i>matz (Yukihiro Matsumoto)</i></li></ul><p>Now we have Enumerable#size, so we can know whether the last character is available or not by it.<br>
So how about changing String#chars to not Array but Enumerator with size and define last method?</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=339892012-11-27T08:15:42Zmarcandre (Marc-Andre Lafortune)marcandre-ruby-core@marc-andre.ca
<ul></ul><p>#size will return <code>nil</code> for all enumerators based on IO.</p>
<p>Maybe the best is to have <code>chars</code> return an array for strings and deprecate it with a warning for IO.</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=340032012-11-27T12:21:13Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Assignee</strong> changed from <i>matz (Yukihiro Matsumoto)</i> to <i>yhara (Yutaka HARA)</i></li></ul><p>Okay, I understand that it may be harmful to change the behavior right now.<br>
Then, let's warn a user to use `each_line' instead in 2.0.0, and change it in future.</p>
<p>Yhara-san, could you create the following type of patch for all methods?</p>
<p>diff --git a/io.c b/io.c<br>
index bacc6fc..26d3970 100644<br>
--- a/io.c<br>
+++ b/io.c<br>
@@ -10795,6 +10795,13 @@ argf_each_line(int argc, VALUE *argv, VALUE argf)<br>
}<br>
}</p>
<p>+static VALUE<br>
+argf_lines(int argc, VALUE *argv, VALUE argf)<br>
+{</p>
<ul>
<li>rb_warn("ARGF#lines will return an Array in future; you should use `each_line' instead");</li>
<li>return argf_each_line(argc, argv, argf);<br>
+}</li>
<li>
</ul>
<p>/*</p>
<ul>
<li>call-seq:</li>
<li>
<pre><code>ARGF.bytes {|byte| block } -> ARGF
</code></pre>
</li>
</ul>
<p>@@ -11557,7 +11564,7 @@ Init_IO(void)<br>
rb_define_method(rb_cARGF, "each_line", argf_each_line, -1);<br>
rb_define_method(rb_cARGF, "each_byte", argf_each_byte, 0);<br>
rb_define_method(rb_cARGF, "each_char", argf_each_char, 0);</p>
<ul>
<li>rb_define_method(rb_cARGF, "lines", argf_each_line, -1);</li>
</ul>
<ul>
<li>rb_define_method(rb_cARGF, "lines", argf_lines, -1);<br>
rb_define_method(rb_cARGF, "bytes", argf_each_byte, 0);<br>
rb_define_method(rb_cARGF, "chars", argf_each_char, 0);</li>
</ul>
<p>--<br>
Yusuke Endoh <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a></p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=340302012-11-27T20:14:30Zknu (Akinori MUSHA)knu@ruby-lang.org
<ul></ul><p>It may be an idea to simply obsolete IO#{lines,chars,codepoints,bytes} for now.</p>
<p>First of all, line wise operation is known to be popular and we've already got #readlines since a long time ago.<br>
So, there is no need for a new IO#lines that returns an array unlike String.</p>
<p>For chars, codepoints and bytes, there is no known need for turning a whole file or stream into an on-memory array because we haven't offered such methods to date.<br>
That may be because character or byte wise operation on a stream is typically done using a seek pointer as it reads lazily.<br>
If this should be the case, we don't have an urgent need for a new IO#chars, #codepoints or #bytes.<br>
However, we, including matz, confirmed in this issue that a method that does not return an array having a name in the plural form is not intuitive because most Enumerator methods have a name consisting of each_ + singular noun, and lines etc. are breaking that convention.</p>
<p>So, what about simply obsoleting IO#{lines,chars,codepoints,bytes} in the current shape?</p>
<p>We can re-add them later in another shape perhaps after we introduce an indexable enumerator (lazy array) that would satisfy everyone who might take both performance and intuitiveness seriously.</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=340392012-11-27T22:21:11Ztrans (Thomas Sawyer)
<ul></ul><p>If I understand correctly, this is going to break a lot of code?</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=340452012-11-27T23:56:52Zknu (Akinori MUSHA)knu@ruby-lang.org
<ul><li><strong>File</strong> <a href="/attachments/3308">0001-Deprecate-lines-bytes-chars-codepoints-of-IO-likes.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/3308/0001-Deprecate-lines-bytes-chars-codepoints-of-IO-likes.patch">0001-Deprecate-lines-bytes-chars-codepoints-of-IO-likes.patch</a> added</li></ul><p>Here's a patch to deprecate #lines, #bytes, #chars and #codepoints of IO-likes.</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=340502012-11-28T01:32:55Zyhara (Yutaka HARA)
<ul></ul><p>trans (Thomas Sawyer) wrote:</p>
<blockquote>
<p>If I understand correctly, this is going to break a lot of code?</p>
</blockquote>
<p>For String, the impact will be limited.</p>
<ul>
<li>
<p>String#lines returns Array, which has most of the methods defined in Enumerator.</p>
</li>
<li>
<p>Exceptions are #next, #peek, #with_index, etc.<br>
If you have a code like <code>str.lines.with_index', you need to change it to </code>str.each_line.with_index'.</p>
</li>
<li>
<p>When you have a huge string, <code>str.lines' will become slower and consume more memory. I think this is a rare case because we usually avoid </code>File.read(path_to_huge_file)'.<br>
Even when you really need huge_str.lines to return Enumerator, you can use huge_str.each_line instead.</p>
</li>
</ul>
<p>For IO/StringIO/ARGF/GzipReader, I'd like to +1 for showing deprecation warning in 2.0.0.</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=340602012-11-28T09:38:28Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<ul></ul><p>Instead of this proposal, what about adding some/most/all of the Array methods to Enumerator?</p>
<p>E.g. like so:</p>
<p>module Enumerator<br>
def [] (pos)<br>
to_a[pos]<br>
end<br>
end</p>
<p>Of course, this is just the simplest case of [], and the simplest (and maybe slowest) implementation. This is just an idea, but I think it would be way better than having to distinguish lines/each_line, chars/each_char,... and so on.</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=340632012-11-28T12:20:32Zyhara (Yutaka HARA)
<ul></ul><p>duerst (Martin Dürst) wrote:</p>
<blockquote>
<p>Instead of this proposal, what about adding some/most/all of the Array methods to Enumerator?</p>
</blockquote>
<p>It is not easy to define behavior of Enumerator#[].<br>
For example:</p>
<p>File.open(path){|f|<br>
ls = f.lines<br>
p lines[0] #=> Prints first line<br>
p lines[0] #=> Prints nil, if #[] is equivalent to #to_a[pos]<br>
}</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=341202012-11-29T14:13:14Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<ul></ul><p>yhara (Yutaka HARA) wrote:</p>
<blockquote>
<p>For String, the impact will be limited.</p>
<ul>
<li>
<p>String#lines returns Array, which has most of the methods defined in Enumerator.</p>
</li>
<li>
<p>Exceptions are #next, #peek, #with_index, etc.<br>
If you have a code like <code>str.lines.with_index', you need to change it to </code>str.each_line.with_index'.</p>
</li>
</ul>
</blockquote>
<p>For with_index in particular, wouldn't it make sense to either add it to Enumerable or deprecate it on Enumerator? That would eliminate one more difference.</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=341292012-11-29T17:12:45Zknu (Akinori MUSHA)knu@ruby-lang.org
<ul><li><strong>Assignee</strong> changed from <i>yhara (Yutaka HARA)</i> to <i>matz (Yukihiro Matsumoto)</i></li></ul><p>We don't have much time left before 2.0 to decide how to change IO#lines, #chars, etc. .<br>
Can we deprecate them for now as a first step as proposed above?</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=342042012-11-30T18:08:50Zyhara (Yutaka HARA)
<ul></ul><p>knu (Akinori MUSHA) wrote:</p>
<blockquote>
<p>Here's a patch to deprecate #lines, #bytes, #chars and #codepoints of IO-likes.</p>
</blockquote>
<p>Maybe we can change StringIO#lines to return Array now because it does not have problems like IO and ARGF.<br>
(problems = return value of IO#lines may be huge or even infinite)</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=342262012-12-01T01:28:11Zdrbrain (Eric Hodel)drbrain@segment7.net
<ul></ul><p>I often use StringIO as an IO substitute for tests. I would prefer matching behavior.</p>
<p>You can get the last line by stringio.string.lines.last. Is this acceptable?</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=342282012-12-01T02:02:54Zyhara (Yutaka HARA)
<ul></ul><p>duerst (Martin Dürst) wrote:</p>
<blockquote>
<p>For with_index in particular, wouldn't it make sense to either add it to Enumerable or deprecate it on Enumerator? That would eliminate one more difference.</p>
</blockquote>
<p>If we add Enumerable#with_index, we could write str.with_index. This does not make sense becuase String#each is not defined.</p>
<p>drbrain (Eric Hodel) wrote:</p>
<blockquote>
<p>I often use StringIO as an IO substitute for tests. I would prefer matching behavior.</p>
<p>You can get the last line by stringio.string.lines.last. Is this acceptable?</p>
</blockquote>
<p>Yes. And I got a reply from <a class="user active user-mention" href="https://bugs.ruby-lang.org/users/8">@knu (Akinori MUSHA)</a>: <a href="https://twitter.com/knu/status/274442544518156288" class="external">https://twitter.com/knu/status/274442544518156288</a><br>
He said "We should not fix API of StringIO before fixing that of IO" and I agreed.</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=350152012-12-23T02:22:07Zknu (Akinori MUSHA)knu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li></ul><p>This issue was solved with changeset r38563.<br>
Yutaka, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<p>Deprecate #{lines,bytes,chars,codepoints} of IO-likes.</p>
<ul>
<li>
<p>io.c (rb_io_lines, rb_io_bytes, rb_io_chars, rb_io_codepoints):<br>
Deprecate IO#{lines,bytes,chars,codepoints} and those of ARGF.<br>
[Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: str.chars.last should be possible (Closed)" href="https://bugs.ruby-lang.org/issues/6670">#6670</a>]</p>
</li>
<li>
<p>ext/stringio/stringio.c (strio_lines, strio_bytes, strio_chars)<br>
(strio_codepoints): Deprecate<br>
StringIO#{lines,bytes,chars,codepoints}. [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: str.chars.last should be possible (Closed)" href="https://bugs.ruby-lang.org/issues/6670">#6670</a>]</p>
</li>
<li>
<p>ext/zlib/zlib.c (rb_gzreader_lines, rb_gzreader_bytes):<br>
Deprecate Zlib::GzipReader#{lines,bytes}. [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: str.chars.last should be possible (Closed)" href="https://bugs.ruby-lang.org/issues/6670">#6670</a>]</p>
</li>
</ul> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=715112018-04-18T06:50:47Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Assigned</i></li><li><strong>Target version</strong> changed from <i>2.0.0</i> to <i>3.0</i></li></ul><p>I have forgotten this ticket completely, and I have used <code>String#lines</code> with a block many times.<br>
Will the methods really stop yielding each line in 3.0? I think that the current behavior (callback only if block is given, and always return an array) is somewhat reasonable, at least, not harmful.<br>
So, how about keeping the current behavior as is?</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=715272018-04-18T16:54:09Zshevegen (Robert A. Heiler)shevegen@gmail.com
<ul></ul><p>While I myself have not needed str.chars.last, I can understand<br>
why Yutaka HARA suggested it. Makes sense to me personally-</p>
<p>One comment on this:</p>
<blockquote>
<p>I feel that the lack of #last is a good thing. It's there<br>
to remind you that it might be expensive, and that (for<br>
example) it would be worth storing in a local var instead<br>
of calling it twice.</p>
</blockquote>
<p>In general, in ruby, speed considerations are not the first<br>
typical thought that may come to every ruby hacker. And there<br>
is a big difference between (a) something that is slow, but<br>
possible, and (b) something that may be slow, but is not<br>
possible. I think in this case, (a) applies and the speed<br>
consideration comes (or should come) secondary - so I don't<br>
feel that using speed as an example, should be something that<br>
speaks against the proposal itself. IMO the question should<br>
be whether this is sufficiently useful or not. I can't answer<br>
this either, but from that point of view, I think the proposal<br>
by Yutaka HARA makes sense. Matz will probably say something<br>
about the suggestion in the upcoming developer meeting. :)</p>
<p>PS: The documentation can also mention whether there are<br>
speed considerations, so I think this is another reason<br>
why speed considerations should not come primary as opposed<br>
to functionality that may be useful (whether it is, I do not<br>
know; just mentioning this in general).</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=759072018-12-26T08:24:55Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Assignee</strong> changed from <i>matz (Yukihiro Matsumoto)</i> to <i>mame (Yusuke Endoh)</i></li></ul><p>Sorry for long absent. We discussed this ticket at DevelopersMeeting20180419Japan, and matz decided to withdraw the deprecation of "String#bytes with block" and friends. I'll remove the deprecation warnings soon.</p> Ruby master - Feature #6670: str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/6670?journal_id=759092018-12-26T14:31:42Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li></ul><p>I committed r66575. I forgot to write the ticket number...</p>