From: Daniel Doubrovkine Date: 2015-09-01T07:09:25-04:00 Subject: [ruby-core:70649] Re: the undefined behavior of an iterator if it is modified inside of the block to which it yields --089e0122ea10407de7051ead9507 Content-Type: text/plain; charset=UTF-8 I completely agree. Behavior of iterators is always defined on some specific type, not in general. I am not proposing to define how &:each behaves for everyone, I propose Ruby defines the iterator behavior in this case on all its core classes, the implementors of other iterators can define their own if they like, just like they would do today. The real world works the same way. The escalator behavior is defined, but not one of all hypothetical stairways. On Mon, Aug 31, 2015 at 9:26 PM, Nobuyoshi Nakada wrote: > On 2015/09/01 1:08, Daniel Doubrovkine wrote: > > I'd like to suggest we change the behavior from "undefined" to "defined" > in some future version of Ruby. It seems that in the real world such > behavior is very well defined, ie. if you're climbing an escalator and a > step appears in front of you before you jump off, you're going to be > stepping on it and not having "undefined" behavior :) > > Your subject is too big. > Since it's implementation issue, so we could define the behaviors of Array > methods, but not other enumerable objects in the world. > -- dB. | Moscow - Geneva - Seattle - New York code.dblock.org - @dblockdotorg - artsy.net - github/dblock --089e0122ea10407de7051ead9507 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I completely agree. Behavior of iterators is always define= d on some specific type, not in general. I am not proposing to define how &= amp;:each behaves for everyone, I propose Ruby defines the iterator behavio= r in this case on all its core classes, the implementors of other iterators= can define their own if they like, just like they would do today.

=
The real world works the same way. The escalator behavior is def= ined, but not one of all hypothetical stairways.

On Mon, Aug 31, 2015 at 9:26 PM,= Nobuyoshi Nakada <nobu@ruby-lang.org> wrote:
On 2015/09/01 1:08, Daniel Doubrovkin= e wrote:
> I'd like to suggest we change the behavior from "undefined&qu= ot; to "defined" in some future version of Ruby. It seems that in= the real world such behavior is very well defined, ie. if you're climb= ing an escalator and a step appears in front of you before you jump off, yo= u're going to be stepping on it and not having "undefined" be= havior :)

Your subject is too big.
Since it's implementation issue, so we could define the behaviors of Ar= ray methods, but not other enumerable objects in the world.



--

dB. | Moscow -= Geneva - Seattle - New York
code.dblock.org=C2=A0-=C2=A0@dblockdotorg<= span style=3D"font-size:11px">=C2=A0-=C2=A0artsy.net=C2=A0-=C2=A0github/dblock

--089e0122ea10407de7051ead9507--