Hi -- On Thu, 23 Jan 2003, Bruce Williams wrote: > On Wednesday 22 January 2003 05:43 pm, Hal E. Fulton wrote: > > | This is general enough that it even covers > | what I call the "non-iterating iterator." > | This comes in one or two varieties, but the > | most common/intuitive is the "open-close" > | kind. See File#open for an example, or > | Mutex#synchronize, or the newer form of > | Dir.chdir (1.7.x). > > Just because it uses a block doesn't make it an iterator; a block is used in > itaration, it does not comprise an iterator. > > File::open, Dir::chdir, and Mutex#synchronize are not 'non-iterating > iterators,' they are merely... not... iterators... because they... don't... > iterate-- they just make use of a handy block (unless someone wants to coin > the phrase 'code between an iteration of state'). I think this is why Hal said that the usage in Ruby is not necessarily exactly the same as the dictionary definition. In Ruby, the presence of a block does cause a method to report itself as an iterator: irb(main):007:0> def it; puts "I'm an iterator!" if iterator?; end => nil irb(main):008:0> it => nil irb(main):009:0> it {} I'm an iterator! => nil ri reports that iterator? (which is a synonym for block_given?) will be removed in 1.8, though that hasn't happened as of 1.8.0preview1. Assuming that does happen, it will bring the terminology more into conformity with what you're describing. David -- David Alan Black home: dblack / candle.superlink.net work: blackdav / shu.edu Web: http://pirate.shu.edu/~blackdav