https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112018-09-13T07:04:14ZRuby Issue Tracking SystemRuby master - Feature #15112: Introducing the short form of `STDERR.puts expr.inspect`.https://bugs.ruby-lang.org/issues/15112?journal_id=740052018-09-13T07:04:14Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<ul></ul><p><code>#warn</code> writes to <code>STDERR</code>. What about <code>warn_p</code> or something similar?</p> Ruby master - Feature #15112: Introducing the short form of `STDERR.puts expr.inspect`.https://bugs.ruby-lang.org/issues/15112?journal_id=740112018-09-13T07:28:59Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul></ul><p>mrkn (Kenta Murata) wrote:</p>
<blockquote>
<p>I sometimes write <code>STDERR.puts obj.inspect</code> to print debug message to standard error.<br>
I want to write it as <code>STDERR.p obj</code>.<br>
It can be realized by introducing <code>p</code> singleton method in <code>STDERR</code> object.</p>
</blockquote>
<p>I've heard it is preferable to use <code>$stderr</code> (the current standard error stream) instead of <code>STDERR</code> (the original standard error stream) as <code>warn</code> and similar methods use <code>$stderr</code>. As <code>$stderr</code> can be reassigned, there is no guarantee that <code>$stderr.p</code> would be valid. I suppose you could have <code>STDERR.p</code> write to <code>$stderr</code>, but that may be confusing. It may be more generally useful to add a method to <code>IO</code> that did the equivalent of <code>puts obj.inspect</code>.</p> Ruby master - Feature #15112: Introducing the short form of `STDERR.puts expr.inspect`.https://bugs.ruby-lang.org/issues/15112?journal_id=740262018-09-13T16:07:34Zshevegen (Robert A. Heiler)shevegen@gmail.com
<ul></ul><p>I agree with both what Kenta Murata and what Jeremy Evans wrote (to explain,<br>
I have no personal preference; I think both <code>.p()</code> would be useful anyway and<br>
I think this was the spirit of the original suggestion; I love p and pp).</p>
<p>Martin suggested <code>warn_p</code> so I think this addresses more Kenta Murata, but I<br>
think, personally, the net benefit of <code>warn_p</code> may be significantly smaller<br>
than the "<code>puts</code>" versus "<code>p</code>" situation, where I think the gain is quite<br>
significant here, if you write a lot of code that makes use of <code>p</code> for<br>
output. (This is a bit similar to the proposal to do "<code>require 'pp'</code>" by<br>
default, which was a good change IMO).</p>
<p>Anyway, my personal opinion is +1 to the idea behind the proposal - I have<br>
no real preference on it being on <code>STDERR</code> or <code>$stderr</code> or both; I think it may<br>
be useful on its own, no matter where the method ultimately resides.</p> Ruby master - Feature #15112: Introducing the short form of `STDERR.puts expr.inspect`.https://bugs.ruby-lang.org/issues/15112?journal_id=741792018-09-24T23:18:19Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>Any object which has <code>#write</code> method can be assigned to <code>$stderr</code>, so we should not expect <code>$stderr</code> to have <code>p</code>, I think.</p> Ruby master - Feature #15112: Introducing the short form of `STDERR.puts expr.inspect`.https://bugs.ruby-lang.org/issues/15112?journal_id=743762018-10-10T05:30:44Zmrkn (Kenta Murata)muraken@gmail.com
<ul><li><strong>Related to</strong> <i><a class="issue tracker-2 status-1 priority-4 priority-default" href="/issues/14609">Feature #14609</a>: Let `Kernel#p` without an argument print the receiver</i> added</li></ul> Ruby master - Feature #15112: Introducing the short form of `STDERR.puts expr.inspect`.https://bugs.ruby-lang.org/issues/15112?journal_id=743782018-10-10T05:51:38Zusa (Usaku NAKAMURA)usa@garbagecollect.jp
<ul></ul><p>I propose more generalized method on <code>IO</code> instead of <code>STDERR.p</code>.<br>
My proposal is <code>IO#putp</code>.</p> Ruby master - Feature #15112: Introducing the short form of `STDERR.puts expr.inspect`.https://bugs.ruby-lang.org/issues/15112?journal_id=744172018-10-12T02:02:50Zmrkn (Kenta Murata)muraken@gmail.com
<ul><li><strong>Subject</strong> changed from <i>Introdudce the new singleton method STDERR.p</i> to <i>Introducing the short form of `STDERR.puts expr.inspect`.</i></li></ul><p>I totally agree with Jeremy and Usaku, so I want to change the title of this issue.</p>