https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112018-09-24T02:47:20ZRuby Issue Tracking SystemRuby master - Feature #15149: extend string format to nil safehttps://redmine.ruby-lang.org/issues/15149?journal_id=741742018-09-24T02:47:20Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>Rather it feels the role of <code>inspect</code>, that is used by <code>%p</code>.<br>
Regarding the compatibility, that new format string can't work with earlier versions.<br>
That means libraries which want to support earlier versions can't use it.</p> Ruby master - Feature #15149: extend string format to nil safehttps://redmine.ruby-lang.org/issues/15149?journal_id=741842018-09-25T00:53:05Zfoonlyboy (Eike Dierks)
<ul></ul><p>Hi nobu,<br>
thanks for your reply, let's talk about this</p>
<p>I believe that <code>%p</code> is for pointers.<br>
Actually <code>%p</code> already behaves like this:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="s1">'%p'</span> <span class="o">%</span> <span class="kp">nil</span> <span class="c1">#=> "nil"</span>
</code></pre>
<p>(I was not aware of that)</p>
<p>Please explain your complaints about compatibility.</p>
<p>This is a new feature<br>
Obviously libraries which want to support earlier versions can not use that new feature.</p>
<p>But adding this new feature would not break <em>any</em> existing code.<br>
(show me code that breaks on this)</p>
<p>I believe this is ruby style:<br>
make things easy</p>
<hr>
<p>We could go down the road of <code>printf</code> formats,<br>
and a lot of programs failed on <code>NULL</code> in <code>printf</code></p>
<p>Once we have this in ruby,<br>
it might even spread out to C++</p>
<p>I still do opt for displaying <code>nil</code> as <code>'nil'</code> (not the empty string)<br>
I should look this up in the standards for the <code>%p</code> conversion</p>
<p>~eike</p> Ruby master - Feature #15149: extend string format to nil safehttps://redmine.ruby-lang.org/issues/15149?journal_id=741852018-09-25T03:22:54Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>foonlyboy (Eike Dierks) wrote:</p>
<blockquote>
<p>I believe that <code>%p</code> is for pointers.</p>
</blockquote>
<p>It's true in C, but Ruby does not show bare pointers.<br>
<code>%p</code> calls <code>inspect</code> instead.</p>
<blockquote>
<p>Please explain your complaints about compatibility.</p>
<p>This is a new feature<br>
Obviously libraries which want to support earlier versions can not use that new feature.</p>
<p>But adding this new feature would not break <em>any</em> existing code.<br>
(show me code that breaks on this)</p>
</blockquote>
<p>I meant that such library would need to stick the old behavior or<br>
branch by the version or runtime checking.</p>