Hi --

On Thu, 12 May 2005, Eric Mahurin wrote:

> inject clearly does what is supposed to.  I'm not referring to
> it.  I'm referring to the following loops that are similar to
> plain while/until/loop loops:
>
> enum.each {|o| ...} -> enum or break value
> enum.each_with_index {|o,i| ...} -> enum  or break value
> for o in enum; ... end -> enum  or break value
> int.times {|i| ...} -> int or break value
> int.downto(stop) {|i| ...} -> int or break value
> int.upto(stop) {|i| ...} -> int or break value
> int.step(stop,step) {|i| ...} -> int or break value
>
> Compare this to the traditional loops:
>
> loop { ... } -> nil or break value
> while ...; ... end -> nil or break value
> until ...; ... end -> nil or break value
> begin ... end while ... -> nil or break value
> begin ... end until ... -> nil or break value
>
> I guess many may not know that break can take a value as an
> argument and make the broken loop return that.  I find this
> behavior quite useful except for those loops that return
> something other than nil in the no-break case (the object loops
> above).
>
> What about the Integer loops above?  Anybody using what those
> return now - the original int?  Maybe I could propose just
> those loops.

I wonder whether some of the non-consensus about the changes you've
been discussing originates in the difference between loop constructs
per se, and iterators.  (loop itself appears to be a method, though
oddly it does not identify itself as an iterator.  But an infinite
loop can't really "return" anything anyway.)

So the non-traditional loops you've listed are basically method calls
(including 'for', which I believe is just an 'each' wrapper).  I don't
know that this has to be a determinant one way or the other, but I
realize it's something that I'd semi-perceived but not quite put my
finger on that separates these things into two pretty distinct
categories.


David

-- 
David A. Black
dblack / wobblini.net