From: Minero Aoki Date: 2002-11-16T22:29:29+09:00 Subject: [ruby-list:36496] ruby-dev summary 18711-18810 あおきです。 普段は ruby-eng ML でまとめてる ruby-dev サマリですが、 ML が止まってるみたいなんで今回はこっちでやらせてください。 [ruby-dev:18651] Enumerable#zip (contd.) Matz has noted some premises about this issue: * The main reason to introduce Enumerable#zip is the parallel iteration (precisely saying, "finite parallel each"). * We should not use Thread/Continuation. * We should not use external iterator (Iterator pattern). * (about zip) We should not raise exceptions when the length is differ between components. Under this condition, following candidates are remained: # Enumerable#zip for x,y in a.zip(b) do ... end a.zip(b).each {|x,y| ...} # Problem: If the length of a and b are differ, # which should we choose? The default value/block does not # resolves this problem, because it is equals to the # "choose longest" strategy. # Enumerable#sync_each a.sync_each(b,c) {|a,b,c| ... } # Problem: "sync_each" is not a good name. Following candidates has been already rejected: # Array.zip --- "Array." is too redundant. for x,y in Array.zip(a,b) do ... end Array.zip(a,b).each {|x,y| ...} # Enumerable#map_with_index --- too long. a.map_with_index {|x,idx| [a, b[idx]] }.each {|x,y| ... } # Array#zip --- Temporal object (an array in this time) # must not be a receiver. for x,y in [a,b].zip do ... end [a,b].zip.each {|x,y| ... } # Kernel#zip --- We already have too many toplevel methods. zip(a,b).each {|x,y| ... } -- この件に関する前提が まつもとさんから提示された。 * zip の主な目的は (有限) 並行 each * Thread や Continuation を使うべきではない * 外部イテレータも使うべきでない * zip にする場合、要素の長さが違っても例外は上げない この前提のもとに不適切ないものをふるいおとした結果、 以下の候補が残った。 # Enumerable#zip for x,y in a.zip(b) do ... end a.zip(b).each {|x,y| ...} # 問題 …… a と b の長さが違うときどうすべきか明確でない。 # デフォルト値 / ブロックは長いほうを選ぶのと同義なので # この問題を解決したことにはならない。 # Enumerable#sync_each a.sync_each(b,c) {|a,b,c| ... } # 問題 …… sync_each という名前は適切だろうか。 以下の候補はすでに却下された。 # Array.zip --- (意味のない) クラス部分が目立ちすぎて冗長 for x,y in Array.zip(a,b) do ... end Array.zip(a,b).each {|x,y| ...} # Enumerable#map_with_index --- 記述が長すぎる。 a.map_with_index {|x,idx| [a, b[idx]] }.each {|x,y| ... } # Array#zip --- 一時的に使うオブジェクトのメソッドになってる # のが (まつもとさんの) 好みじゃない。 for x,y in [a,b].zip do ... end [a,b].zip.each {|x,y| ... } # Kernel#zip --- いまさらトップレベルかよ zip(a,b).each {|x,y| ... } [ruby-dev:18711] another implementation of pstore Current pstore.rb is possible to break a database file when a ruby process is interrupted on some timings. YANAGAWA Kazuhisa has announced his implementation of pstore.rb, which resolves such problems. You can get his program from here: http://www.dm4lab.to/~kjana/ruby/ps.tar.gz NOTE: He is NOT intent on replacing current implementation. This is just a sample. -- 現在の pstore.rb の実装では、あるタイミングでプロセスが中断すると データベースファイルが壊れてしまうことがある。この問題を修正した 版が柳川さんによって公開された。以下の URL から取得できる。 http://www.dm4lab.to/~kjana/ruby/ps.tar.gz ※ 標準ライブラリを置き換えようという意図はない。 将来には結果的にそういうことになるかもしれないが、 現時点ではそうではない。 [ruby-dev:18718] ruby 1.6.8 preview 2 Matz has released ruby 1.6.8 preview 2. ftp://ftp.ruby-lang.org/pub/ruby/1.6/ruby-1.6.8-preview2.tar.gz [ruby-dev:18739] change chomp! Shin-ichiro HARA has suggested that String#chomp should cut off CR and LR at once. Knu has pointed out ruby 1.7 already acts like such. -- String#chompは \r\n を一度に削除すべきではないかという意見が 出たが、ruby 1.7 は既にそのように変更されているとのこと。