Ruby Issue Tracking System: Issueshttps://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112016-06-07T10:02:21ZRuby Issue Tracking System
Redmine Ruby master - Bug #12467 (Third Party's Issue): Open mode 'a' does not work for Process.spawn on ...https://bugs.ruby-lang.org/issues/124672016-06-07T10:02:21Zyhara (Yutaka HARA)
<p>Example:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">spawn</span> <span class="s1">'ruby -e "p Time.now"'</span><span class="p">,</span> <span class="p">[</span><span class="ss">:out</span><span class="p">,</span> <span class="ss">:err</span><span class="p">]</span> <span class="o">=></span> <span class="p">[</span><span class="s1">'log.txt'</span><span class="p">,</span> <span class="s1">'a'</span><span class="p">]</span>
<span class="nb">sleep</span> <span class="mi">1</span>
<span class="n">spawn</span> <span class="s1">'ruby -e "p Time.now"'</span><span class="p">,</span> <span class="p">[</span><span class="ss">:out</span><span class="p">,</span> <span class="ss">:err</span><span class="p">]</span> <span class="o">=></span> <span class="p">[</span><span class="s1">'log.txt'</span><span class="p">,</span> <span class="s1">'a'</span><span class="p">]</span>
<span class="nb">sleep</span> <span class="mi">1</span>
<span class="nb">p</span> <span class="no">File</span><span class="p">.</span><span class="nf">read</span><span class="p">(</span><span class="s1">'log.txt'</span><span class="p">)</span>
</code></pre>
<p>This program looks work correctly at first.</p>
<pre><code>c:\>ruby spawn_bug.rb
"2016-06-07 18:47:25 +0900\n2016-06-07 18:28:17 +0900\n"
</code></pre>
<p>However, when I run it again, the log file is truncated like 'w' flag.</p>
<pre><code>c:\>ruby spawn_bug.rb
"2016-06-07 18:47:38 +0900\n2016-06-07 18:28:17 +0900\n"
</code></pre>
<p>This is the same if I open the log file manually with File.open.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">f</span> <span class="o">=</span> <span class="no">File</span><span class="p">.</span><span class="nf">open</span><span class="p">(</span><span class="s1">'log.txt'</span><span class="p">,</span> <span class="s1">'a'</span><span class="p">)</span>
<span class="n">spawn</span> <span class="s1">'ruby -e "p Time.now"'</span><span class="p">,</span> <span class="p">[</span><span class="ss">:out</span><span class="p">,</span> <span class="ss">:err</span><span class="p">]</span> <span class="o">=></span> <span class="n">f</span>
<span class="nb">sleep</span> <span class="mi">1</span>
<span class="n">spawn</span> <span class="s1">'ruby -e "p Time.now"'</span><span class="p">,</span> <span class="p">[</span><span class="ss">:out</span><span class="p">,</span> <span class="ss">:err</span><span class="p">]</span> <span class="o">=></span> <span class="n">f</span>
<span class="nb">sleep</span> <span class="mi">1</span>
<span class="nb">p</span> <span class="no">File</span><span class="p">.</span><span class="nf">read</span><span class="p">(</span><span class="s1">'log.txt'</span><span class="p">)</span>
</code></pre>
<p>I tried this on Windows 10. (Also confirmed this does not happen on Mac OS X 10.11 + ruby 2.2)</p> Ruby master - Feature #10208 (Closed): Passing block to Enumerable#to_hhttps://bugs.ruby-lang.org/issues/102082014-09-06T04:25:27Zyhara (Yutaka HARA)
<p>Now that we can convert 'a list of [key, value] pairs' into a hash with Enumerable#to_h,<br>
how about make it take a block to specify 'how to convert each element into a [key, value] pair'?</p>
<p>Example:</p>
<pre><code># Convert users into an {id => name} hash
users.map{|u| [u.id, u.name]}.to_h
↓
# Convert users into an {id => name} hash
users.to_h{|u| [u.id, u.name]}
</code></pre>
<p>This could also be a solution for these feature requests:</p>
<ul>
<li>
<p>Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: A method like Hash#map but returns hash (Closed)" href="https://bugs.ruby-lang.org/issues/6669">#6669</a> A method like Hash#map but returns hash</p>
<pre><code> hsh.apply{|k, v| [k.to_s, v]}
== hsh.to_h{|k, v| [k.to_s, v]}
</code></pre>
</li>
<li>
<p>Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: New methods on Hash (Closed)" href="https://bugs.ruby-lang.org/issues/7793">#7793</a> New methods on Hash<br>
Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Add `Hash#map_keys` and `Hash#map_values` (Closed)" href="https://bugs.ruby-lang.org/issues/9970">#9970</a> Add <code>Hash#map_keys</code> and <code>Hash#map_values</code></p>
<pre><code> hsh.map_k(&:to_s)
== hsh.to_h{|k, v| [k.to_s, v]}
hsh.map_v(&:to_i)
== hsh.to_h{|k, v| [k, v.to_i]}
hsh.map_kv(&block)
== hsh.to_h(&block)
</code></pre>
</li>
</ul> Ruby master - Bug #8590 (Closed): Second call of https.get results in timeouthttps://bugs.ruby-lang.org/issues/85902013-07-01T21:07:55Zyhara (Yutaka HARA)
<p>Hi,</p>
<p>In the following code, second call of https.get results in an error "Connection reset by peer - SSL_connect" after timeout.</p>
<hr>
<p>require "net/https"<br>
https = Net::HTTP.new("secure.nicovideo.jp", 443)<br>
#https = Net::HTTP.new("www.sbisec.co.jp", 443) # same result for this server</p>
<h2>https.use_ssl = true<br>
https.ssl_version = 'TLSv1'<br>
https.start{ p https.get('/') } #=> OK<br>
https.start{ p https.get('/') } #=> (Timeout)</h2>
<p>Expected: prints response twice</p>
<p>Actual: prints response once, and raises the following error after timeout</p>
<p>/Users/yhara/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/net/http.rb:918:in <code>connect': Connection reset by peer - SSL_connect (Errno::ECONNRESET) from /Users/yhara/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/net/http.rb:918:in </code>block in connect'<br>
from /Users/yhara/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/timeout.rb:52:in <code>timeout' from /Users/yhara/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/net/http.rb:918:in </code>connect'<br>
from /Users/yhara/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/net/http.rb:862:in <code>do_start' from /Users/yhara/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/net/http.rb:851:in </code>start'</p>
<p>Is this a bug of Net::HTTP, or a problem of the server, or just I'm doing something wrong?</p>
<p>Thanks in advance.</p> Ruby master - Bug #8242 (Closed): Fix rdoc of Range#bsearchhttps://bugs.ruby-lang.org/issues/82422013-04-09T23:35:02Zyhara (Yutaka HARA)
<p>rdoc of Range#bsearch states "the elements must be sorted", but it does not make sense for Range.</p>
<p>Patch:</p>
<p>diff --git a/range.c b/range.c<br>
index 1e4347e..fab0718 100644<br>
--- a/range.c<br>
+++ b/range.c<br>
@@ -512,11 +512,10 @@ is_integer_p(VALUE v)</p>
<ul>
<li>
<pre><code>rng.bsearch {|obj| block } -> value
</code></pre>
</li>
<li>
<li>By using binary search, finds a value in range which meets the given</li>
</ul>
<ul>
<li>
<ul>
<li>condition in O(log n) where n is the size of the array.</li>
</ul>
</li>
</ul>
<ul>
<li>
<ul>
<li>condition in O(log n) where n is the size of the range.</li>
<li>
<li>You can use this method in two use cases: a find-minimum mode and</li>
</ul>
</li>
</ul>
<ul>
<li>
<ul>
<li>a find-any mode. In either case, the elements of the array must be</li>
</ul>
</li>
<li>
<ul>
<li>monotone (or sorted) with respect to the block.</li>
</ul>
</li>
</ul>
<ul>
<li>
<ul>
<li>a find-any mode.</li>
<li>
<li>In find-minimum mode (this is a good choice for typical use case),</li>
<li>the block must return true or false, and there must be a value x<br>
@@ -524,7 +523,7 @@ is_integer_p(VALUE v)</li>
<li>
<li>
<ul>
<li>the block returns false for any value which is less than x, and</li>
</ul>
</li>
<li>
<ul>
<li>the block returns true for any value which is greater than or</li>
</ul>
</li>
</ul>
</li>
</ul>
<ul>
<li>
<ul>
<li>equal to i.</li>
</ul>
</li>
</ul>
<ul>
<li>
<ul>
<li>equal to x.</li>
<li>
<li>If x is within the range, this method returns the value x.</li>
<li>Otherwise, it returns nil.</li>
</ul>
</li>
</ul> Ruby master - Bug #7507 (Closed): lazy.map{}.zip{} causes SEGVhttps://bugs.ruby-lang.org/issues/75072012-12-04T14:00:41Zyhara (Yutaka HARA)
<p>The following program causes SEGV. (Tested on Mac and Ubuntu)</p>
<p>(1..10000).lazy.map{}.zip(){}</p>
<hr>
<p>/Users/yhara/r/ruby % ./miniruby -e '(1..10000).lazy.map{}.zip(){}'<br>
-e:1: [BUG] Segmentation fault<br>
ruby 2.0.0dev (2012-12-04 trunk 38172) [x86_64-darwin12.2.1]</p>
<p>-- Control frame information -----------------------------------------------<br>
c:0015 p:---- s:0031 e:000030 IFUNC<br>
c:0014 p:---- s:0029 e:000028 IFUNC<br>
c:0013 p:---- s:0027 e:000026 CFUNC :yield<br>
c:0012 p:---- s:0025 e:000024 IFUNC<br>
c:0011 p:---- s:0023 e:000022 CFUNC :each<br>
c:0010 p:---- s:0021 e:000020 IFUNC<br>
c:0009 p:---- s:0019 e:002020 CFUNC :each<br>
c:0008 p:---- s:0017 e:000016 CFUNC :each<br>
c:0007 p:---- s:0015 e:001f70 IFUNC<br>
c:0006 p:---- s:0013 e:001eb0 CFUNC :each<br>
c:0005 p:---- s:0011 e:000010 CFUNC :each<br>
c:0004 p:---- s:0009 e:001e00 CFUNC :zip<br>
c:0003 p:---- s:0007 e:000006 CFUNC :zip<br>
c:0002 p:0012 s:0004 e:001928 EVAL -e:1 [FINISH]<br>
c:0001 p:0000 s:0002 e:001468 TOP [FINISH]</p>
<h2>-e:1:in <code><main>' -e:1:in </code>zip'<br>
-e:1:in <code>zip' -e:1:in </code>each'<br>
-e:1:in <code>each' -e:1:in </code>each'<br>
-e:1:in <code>each' -e:1:in </code>each'<br>
-e:1:in `yield'<br>
(snip)</h2> Ruby master - Bug #7440 (Rejected): IO#lines etc. should return Arrayhttps://bugs.ruby-lang.org/issues/74402012-11-27T00:46:38Zyhara (Yutaka HARA)
<p>String#bytes, #chars, #codepints and #lines are changed to return Array in <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>
<p>For consistent behavior, following methods should return Array too:</p>
<ul>
<li>ARGF.lines, chars, bytes, codepoints</li>
<li>IO#lines, chars, bytes, codepoints</li>
<li>StringIO#lines, chars, bytes, codepoints</li>
<li>Zlib::GzipReader#lines, bytes</li>
</ul>
<p>Please let me know if there are more.</p> Backport193 - Backport #7438 (Closed): ARGF.codepoints is not definedhttps://bugs.ruby-lang.org/issues/74382012-11-26T16:08:59Zyhara (Yutaka HARA)
<p>String, IO and StringIO have #bytes, #chars, #lines and #codepoints.</p>
<p>ARGF has #bytes, #chars and #lines, but does not have #codepoints.</p> Ruby master - Feature #6670 (Closed): str.chars.last should be possiblehttps://bugs.ruby-lang.org/issues/66702012-06-30T02:52:10Zyhara (Yutaka HARA)
<p>=begin<br>
Since str.chars returns an Enumerator, we need explicit to_a for some operations:</p>
<p>str.chars.to_a.last<br>
str.chars.to_a[1,3]</p>
<p>But often I forget that and write:</p>
<p>str.chars.last<br>
str.chars[1,3]</p>
<p>Besides that, I feel it is hard to explain why to_a is needed here when I'm writing<br>
artilcles for Ruby beginners.</p>
<p>Simplest way to achieve this is to make String#chars (also #lines, #bytes and #codepoints)<br>
return an Array. Since arrays have most of the methods defined in Enumerator, this will<br>
not be a big change. For programs like str.chars.next, you can use each_char instead.<br>
=end</p> Ruby master - Feature #6669 (Closed): A method like Hash#map but returns hashhttps://bugs.ruby-lang.org/issues/66692012-06-30T02:23:10Zyhara (Yutaka HARA)
<p>Given a hash <code>h</code>, <code>h.map</code> returns an array(alist), but sometimes I hope it returned a hash.</p>
<p>Example:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">class</span> <span class="nc">Hash</span>
<span class="k">def</span> <span class="nf">apply</span><span class="p">(</span><span class="o">&</span><span class="n">block</span><span class="p">)</span>
<span class="nb">self</span><span class="p">.</span><span class="nf">inject</span><span class="p">({})</span> <span class="k">do</span> <span class="o">|</span><span class="n">h</span><span class="p">,</span> <span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span><span class="o">|</span>
<span class="n">new_k</span><span class="p">,</span> <span class="n">new_v</span> <span class="o">=</span> <span class="o">*</span><span class="n">block</span><span class="p">.</span><span class="nf">call</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span>
<span class="n">h</span><span class="p">[</span><span class="n">new_k</span><span class="p">]</span> <span class="o">=</span> <span class="n">new_v</span>
<span class="n">h</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="n">score</span> <span class="o">=</span> <span class="p">{</span>
<span class="ss">taro: </span><span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">2</span><span class="p">],</span>
<span class="ss">jiro: </span><span class="p">[</span><span class="mi">3</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">8</span><span class="p">,</span><span class="mi">4</span><span class="p">],</span>
<span class="ss">saburo: </span><span class="p">[</span><span class="mi">2</span><span class="p">,</span><span class="mi">9</span><span class="p">]</span>
<span class="p">}</span>
<span class="n">max_score</span> <span class="o">=</span> <span class="n">score</span><span class="p">.</span><span class="nf">apply</span><span class="p">{</span><span class="o">|</span><span class="n">k</span><span class="p">,</span><span class="n">v</span><span class="o">|</span> <span class="p">[</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">.</span><span class="nf">max</span><span class="p">]}</span>
<span class="c1">#=> {taro: 3, jiro: 8, saburo: 9}</span>
<span class="nb">p</span> <span class="n">max_score</span><span class="p">[</span><span class="ss">:taro</span><span class="p">]</span>
<span class="c1">#=> 3</span>
</code></pre>
<p>I'm not thinking "<code>apply</code>" is a perfect name for this. Maybe "<code>hash_map</code>" is better<br>
(we already have "<code>flat_map</code>").</p> Ruby master - Feature #4890 (Closed): Enumerable#lazyhttps://bugs.ruby-lang.org/issues/48902011-06-16T19:23:31Zyhara (Yutaka HARA)
<p>=begin<br>
= Example<br>
Print first 100 primes which are in form of n^2+1</p>
<p>require 'prime'<br>
INFINITY = 1.0 / 0<br>
p (1..INFINITY).lazy.map{|n| n**2+1}.select{|m| m.prime?}.take(100)</p>
<p>(Example taken from enumerable_lz; thanks @antimon2)</p>
<p>= Description</p>
<p>Enumerable#lazy returns an instance of Enumerable::Lazy.<br>
This is the only method added to the existing bulit-in classes.</p>
<p>Lazy is a subclass of Enumerator, which includes Enumerable.<br>
So you can call any methods of Enumerable on Lazy, except methods like<br>
map, select, etc. are redefined as 'lazy' versions.</p>
<p>= Sample implementation</p>
<p>((<a href="URL:https://gist.github.com/1028609" class="external">URL:https://gist.github.com/1028609</a>))<br>
(also attached to this ticket)</p>
<p>=end</p> Ruby master - Bug #4554 (Closed): test_set_errors in test_x509store.rb fails on CentOS 5.5https://bugs.ruby-lang.org/issues/45542011-04-05T14:33:44Zyhara (Yutaka HARA)
<p>=begin<br>
On CentOS 5.5, test_set_errors in test_x509store.rb fails as follows:</p>
<p>1.9.2 p180</p>
<ol>
<li>Failure:<br>
test_set_errors(OpenSSL::TestX509Store) [/var/home/yhara/ruby-1.9.2-p180/test/openssl/test_x509store.rb:212]:<br>
OpenSSL::X509::StoreError expected but nothing was raised.</li>
</ol>
<p>1.8.7 p334</p>
<ol>
<li>Failure:<br>
test_set_errors(OpenSSL::TestX509Store) [./test/openssl/test_x509store.rb:212]:<br>
<a href="OpenSSL::X509::StoreError" class="external">OpenSSL::X509::StoreError</a> exception expected but none was thrown.</li>
</ol>
<p>test_set_errors asserts that OpenSSL::X509::Store#add_crl raises an exception<br>
when two CRLs issued by same CA are added to the store.</p>
<p>However, the openssl package provided by CentOS are patched not to treat this<br>
as an error (multi-crl.patch).</p>
<p>=end</p> Backport192 - Backport #4542 (Rejected): test_threaded_flush sometimes failshttps://bugs.ruby-lang.org/issues/45422011-03-31T21:15:51Zyhara (Yutaka HARA)
<p>=begin<br>
test-all of Ruby 1.9.2 p180 sometimes shows the following error:</p>
<ol start="2">
<li>Failure:<br>
test_threaded_flush(TestIO) [/var/home/yhara/ruby-1.9.2-p180/test/ruby/test_io.rb:1670]:<br>
<[""hi!""]> expected but was<br>
<[]>.</li>
</ol>
<p>Unfortunately, this rarely reproduces.</p>
<ul>
<li>1 of 10 tries on CentOS 5.5</li>
<li>1 on Ubuntu 10.10<br>
=end</li>
</ul> Backport192 - Backport #4540 (Closed): ext/-test-/string/extconf.rb is missing in Ruby 1.9.2https://bugs.ruby-lang.org/issues/45402011-03-30T15:49:09Zyhara (Yutaka HARA)
<p>=begin<br>
test-all of Ruby 1.9.2 p180 shows the following error:</p>
<p>/home/yhara/temp/ruby-1.9.2-p180/test/-ext-/string/test_cstr.rb: no such file to load -- -test-/string/string</p>
<p>Ruby trunk has ext/-test-/string/extconf.rb, but that file is missing in branch 1_9_2.</p>
<p>tested on Ubuntu 10.10 and CentOS 5.5<br>
=end</p> Ruby master - Bug #4519 (Closed): rubygems/test_gem_package_task.rb breaks rake/test_filelist.rbhttps://bugs.ruby-lang.org/issues/45192011-03-23T17:53:29Zyhara (Yutaka HARA)
<p>=begin<br>
test-all of Ruby 1.9.2 p180 fails as follows on CentOS 5.5.</p>
<p>test_array_comparisons(Rake::TestFileList) [/home/yhara/ruby-1.9.2-p180/test/rake/test_filelist.rb:462]:<br>
<1> expected but was<br>
.</p>
<p>This happens when test/rubygems/ is executed before test/rake/.</p>
<p>To reproduce this: (tested on Ubuntu 10.10 and Mac OS X 10.5.8)</p>
<p>(1) Edit test/runner.rb as follows<br>
(2) make test-all</p>
<p>(...snip...)<br>
Test::Unit.setup_argv {|files|<br>
(...snip...)<br>
end</p>
<p>["test/rubygems/test_gem_package_task.rb", "test/rake/test_filelist.rb"]<br>
}</p>
<p>=end</p> Ruby master - Bug #4001 (Closed): RubyVM::InstructionSequence.compile can not take the 5th argumenthttps://bugs.ruby-lang.org/issues/40012010-10-29T17:44:01Zyhara (Yutaka HARA)
<p>=begin<br>
InstructionSequence.compile takes src, file, path, line, opt<br>
as the arguments, but raises ArgumentError when opt is given.</p>
<p>Example:</p>
<p>$ ruby -e 'p RubyVM::InstructionSequence.compile("", "", "", 1, {})'<br>
-e:1:in `compile': wrong number of arguments (5 for 1..4) (ArgumentError)</p>
<p>Patch:</p>
<a name="Index-iseqc"></a>
<h1 >Index: iseq.c<a href="#Index-iseqc" class="wiki-anchor">¶</a></h1>
<p>--- iseq.c (revision 29626)<br>
+++ iseq.c (working copy)<br>
@@ -581,7 +581,7 @@</p>
<pre><code> rb_secure(1);
</code></pre>
<ul>
<li>rb_scan_args(argc, argv, "13", &src, &file, &path, &line, &opt);</li>
</ul>
<ul>
<li>rb_scan_args(argc, argv, "14", &src, &file, &path, &line, &opt);<br>
if (NIL_P(file)) file = rb_str_new2("");<br>
if (NIL_P(line)) line = INT2FIX(1);<br>
=end</li>
</ul> Ruby master - Feature #1961 (Closed): Kernel#__dir__https://bugs.ruby-lang.org/issues/19612009-08-19T23:57:05Zyhara (Yutaka HARA)
<p>=begin<br>
= Proposal</p>
<p>Kernel#<strong>dir</strong><br>
returns the value of File.dirname(<strong>FILE</strong>)</p>
<p>According to the google code search, about 60% of uses of <strong>FILE</strong><br>
are of the form File.dirname(<strong>FILE</strong>). Ruby 1.9.2 provides<br>
require_relative for this problem; but File.dirname(<strong>FILE</strong>) is<br>
not always used for requiring ruby scripts, but also for reading<br>
data files. <strong>dir</strong> helps these cases.</p>
<p>(Note: my proposal does not include <strong>dir_dir</strong> this time :-)<br>
It should be discussed in another threads)<br>
Related ticket: <a href="http://redmine.ruby-lang.org/issues/show/642" class="external">http://redmine.ruby-lang.org/issues/show/642</a></p>
<p>= Problem</p>
<p>File.dirname(<strong>FILE</strong>) is frequently used and too long.</p>
<p>= Analysis</p>
<p>There are 222 uses of <strong>FILE</strong> listed by the google code search,<br>
classified into these categories:</p>
<p>(A) 30.6% (68) are used with require and File.dirname.<br>
In Ruby 1.9.2, this case is supported by require_relative.</p>
<p>(B) 31.1% (69) are with File.dirname, but not with require.<br>
For example, reading data files of unit tests.</p>
<p>(C) 21.6% (48) are the idiom, $0 == <strong>FILE</strong>.</p>
<p>B is as many as A (and even more than C), so it is reasonable to<br>
add a shortcut for File.dirname(<strong>FILE</strong>) in addition to require_relative.</p>
<ul>
<li>code: <a href="http://gist.github.com/170336" class="external">http://gist.github.com/170336</a>
</li>
<li>result: <a href="http://route477.net/files/__file__.html" class="external">http://route477.net/files/__file__.html</a>
</li>
</ul>
<p>= Solutions</p>
<p>(1) add a toplevel constant <strong>DIR</strong><br>
pros: looks like <strong>FILE</strong><br>
cons: adding new keyword</p>
<p>(2) add Kernel#<strong>DIR</strong><br>
pros: no new keyword<br>
cons: it should have a lower-case name (like 1.9's <strong>method</strong>),<br>
because it is not a constant but a method.</p>
<p>(3) add Kernel#<strong>dir</strong><br>
pros: no new keyword, and it is clearer than (4) that it has<br>
some associations with <strong>FILE</strong>.</p>
<p>(4) make <strong>FILE</strong> to the default argument of File.dirname<br>
pros: no new keyword nor new method<br>
cons: it is not clear that 'File.dirname' is expanded to<br>
the path of directory of <strong>FILE</strong>.</p>
<p>= Conclusion</p>
<p>I think (3) (Kernel#<strong>dir</strong>) is the best.</p>
<a name="Thanks"></a>
<h2 >Thanks,<a href="#Thanks" class="wiki-anchor">¶</a></h2>
<p>yhara (Yutaka HARA)<br>
<a href="http://route477.net/" class="external">http://route477.net/</a><br>
=end</p>