But then you get a different behaviour then for a mapping? (Array and string indexes can't change, so they don't matter here.)
Is that behaviour useful in a practical situation? To me, the risk of bugs is obvious, but then again most bugs I can think of would lead to infinite loops and thus detected easily.
( Like, multiset m; ... foreach (m;;int x) m[x+10000]=1; )
/ Mirar
Previous text:
2003-01-30 20:27: Subject: Multiset iterator
I thought it to be more useful to not have any restriction. Then you can e.g. go through a set and add and remove items as you go, and there will be no copy-on-write overhead and you will reach the newly added items if they're inserted ahead of the iterator. To me that's more natural than a frozen index set with copy-on-write, i.e. if the case wasn't mentioned in a manual that's how I'd assume it to be.
Other more unusual operations are made possible too, e.g. to store two iterators (perhaps pointers would be a more appropriate name in this case) that are next to each other, and then at a later point do some operation on the elements that have been inserted in between. The difference from simply looking them up again is that it will be completely well defined even if the indices are identical.
/ Martin Stjernholm, Roxen IS