Dan North wrote:
> So it's undefined behaviour, but "Don't modify the receiver while you 
> are iterating over it." :)
> 
> Can I suggest the solution that Java uses, which is to fail fast in that 
> situation (ConcurrentModificationException). You would not believe how 
> much debugging time that one tiny feature has saved me!

I think throwing an exception falls under "exact behavior." :)
And detecting this situation would be non-trivial, and proabably
not worthwhile anyway. I'm happy enough with the admonition
"Just Don't Do It" (opposite of Nike).

Shame on me for allowing this (pp 152-153) to have found its way
into print.

Hal


> Cheers,
> Dan
> 
> Yukihiro Matsumoto wrote:
> 
>> Hi,
>>
>> In message "Re: #collect with block modifying receiver"
>>    on 03/08/29, Hal Fulton <hal9000 / hypermetrics.com> writes:
>>
>> |OK, so this *really* makes me wonder what the "theoretically correct"
>> |behavior is.
>>
>> |Matz, are you listening?? Enlighten us, please...
>>
>> Ah, listen, it's undefined behavior. ;-)
>>
>> To be serious, I don't want to slow down performance by defining any
>> exact behavior.  Don't modify the receiver while you are iterating
>> over it.
>>
>>                             matz.
>>
>>  
>>
> -- 
> Dan North
> http://www.thoughtworks.com
> 
> 
> 
>