SyncEnumerator

Ok. Then I'd like to suggest replacing the existing SyncEnumerator in
Generator.rb with the one I've provided.

···

On Sunday 07 November 2004 17:49, Yukihiro Matsumoto wrote:

    on Mon, 8 Nov 2004 04:08:36 +0900, gabriele renzi
    > >but /just/ making something faster seems a ruby-core thing, cause it
    > >is
    > >better in everyone's point of view (well, except for making
    > >sleep()
    > > faster)

I thing making something faster without changing behavior would do
nothing with RCR from the beginning.

--
### SER
### Deutsch|Esperanto|Francaise|Linux|XML|Java|Ruby|Aikido
### http://www.germane-software.com/~ser jabber.com:ser ICQ:83578737
### GPG: http://www.germane-software.com/~ser/Security/ser_public.gpg

["Sean E. Russell" <ggg@ser1.net>, 2004-11-09 14.06 CET]

Ok. Then I'd like to suggest replacing the existing SyncEnumerator in
Generator.rb with the one I've provided.

But:

  class SyncEnumerator2
    ...
  end

  f = File.new("/etc/passwd")
  g = 0..10
  SyncEnumerator2.new(f, g).each do |line, nr| print nr, ": ", line end

produces:

  p.rb:11:in `initialize': undefined method `size' for #<File:/etc/passwd> (NoMethodError)
          from p.rb:11:in `each'
          from p.rb:11:in `initialize'
          from p.rb:37:in `new'
          from p.rb:37

···

--

Is the SyncEnumerator method 'end?' from the original implementation in
generator.rb part of the public interface? If so, is it okay that the
proposed alternative doesn't provide it?

Another difference that may be worth considering is that the
non-continuation based implementation can't (I think - please correct me
here) handle Enumerables that can only be enumerated once. An example
would be a file, socket or a pipe.

SyncEnumerator1 uses to index the Enumerable, so it would be
necessary to update the documentation to explicitly indicate that objects
supporting are required. The same applies for the use of the 'size'
method.

SyncEnumerator2 uses zip which converts to arrays internally if necessary.
What are the memory implications of using SyncEnumerator2 as opposed to
the current SyncEnumerator with, for example, two very large files?

I suppose the above boils down to: the SyncEnumerator improvements
primarily apply to array-like objects, so I'd like to see the
Generator-based implementation remain, somewhere.

Thanks.

···

On Tue, 09 Nov 2004 22:06:58 +0900, Sean E. Russell wrote:

On Sunday 07 November 2004 17:49, Yukihiro Matsumoto wrote:

I thing making something faster without changing behavior would do
nothing with RCR from the beginning.

Ok. Then I'd like to suggest replacing the existing SyncEnumerator in
Generator.rb with the one I've provided.

Speaking of which, I tend to think #begin and #end, and the like named methods
make terrible method names. Do others agree? Should these be dprecated in
favor of others?

T.

···

On Wednesday 10 November 2004 07:53 am, Jonathan Paisley wrote:

Is the SyncEnumerator method 'end?' from the original implementation in
generator.rb part of the public interface? If so, is it okay that the
proposed alternative doesn't provide it?