"Minero Aoki" <aamine / loveruby.net> wrote in message
news:20021118181718N.aamine / mx.edit.ne.jp...
> Hi all,
>
> This is a summary of ruby-dev ML in these days.
>
> [ruby-dev:18651] Enumerable#zip (contd.)
>

Aplying zip as an instance method to the module Enumerable makes the method
assymetric. There is the object left to the method name, and its parameters.
But in mind the operation is symmetrical except the order is significant.
Where should the object be placed in sequence?

>   Matz has noted some preconditions about this issue:
>
>     * The main reason to introduce Enumerable#zip is the parallel
>       iteration (to be precise, "finite parallel each").
>
>     * We should not use Thread/Continuation.
>
>     * We should not use external iterator (Iterator pattern).
>
>     * (on zip) We should not raise exceptions when the length of the
>       components are differ.


If the longest sequence would be chosen, what value should receive the
absent items?
While the exception will not be raised how can one know if the sequences
have different lengths?

>
>   Under these conditions, 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 different,
>         # which one should we choose?  The default value/block does
>         # not resolve this problem, because it is equal 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 have been already rejected:
>
>     # Array.zip --- "Array." is too redundant for our aim.
>     for x,y in Array.zip(a,b) do ... end
>     Array.zip(a,b).each {|x,y| ...}
>
>     # Enumerable#map_with_index --- too long description.
>     a.map_with_index {|x,idx| [a, b[idx]] }.each {|x,y| ... }
>
>     # Array#zip --- Temporal object (an array in this case)
>     #               should 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| ... }
>
> [ruby-dev:18711] another implementation of pstore
>
>   Current pstore.rb may crash a database file when a ruby process
>   is interrupted on certain bad timings. YANAGAWA Kazuhisa announced
>   his implementation of pstore.rb, which resolves such problems.
>
>   You can get it from:
>
>     http://www.dm4lab.to/~kjana/ruby/ps.tar.gz
>
>   NOTE: He does NOT intend on replacing current implementation.
>   This is just a sample, by now.
>
> [ruby-dev:18739] change chomp!
>
>   Shin-ichiro HARA suggested that String#chomp should cut off
>   CR and LR at once.  Knu pointed out that ruby 1.7 already acts
>   like such.
>
>
> -- Minero Aoki
>