----- Original Message ----- From: "David Alan Black" <dblack / candle.superlink.net> To: "ruby-talk ML" <ruby-talk / ruby-lang.org> Sent: Monday, August 05, 2002 4:37 PM Subject: Re: Super-iterator? (long) > Just for fun, I've converted your tests to Test::Unit format. This is > a drop-in replacement for everything after the module Enumerable > extensions. Neat. I need to get into that habit. > A few comments: > > 1. I'm still not sold on the whole thing :-) But it's extremely > interesting. Oh, neither am I (completely sold). It's an experiment. I'm sold on my own "motivations" but not on this solution. > 2. I had to change #next to #i_next, because it was next'ing integers and > characters. Huh?? next is a method of IteratorVar... it shouldn't cause any kind of conflict. Can you explain? > 3. #odd? and #even? are, in my view, too "meta". When I see "x.odd?", > it's virtually impossible not to expect that it's testing an integer > for oddness. I agree. But I couldn't think of what else to call them. When I want to do things alternately in a loop, sometimes I want the even-numbered iterations, and sometimes the odd. > 4. Are you sure you want #next (or #i_next, or whatever) to consume > items? What if you want to grab the next item, but also want to > iterate to that item in the normal way? You seem to have less > functionality here (if I'm right about that) than you would with one > of the "index" methods. According to my own usage patterns, I usually do want it to consume. If I were writing some kind of parser, it might be different. > 5. I've done some fancy #to_s'ing... not sure if I should have to do > that. Anyway, I've done it, just to get the tests to pass initially. Actually, according to the way I was doing things, I should have said x.next.value instead of just x.next (assuming no one actually wants to store an IteratorVar). Maybe that would help. Hal