to invalidate a range
ellery-newcomer at utulsa.edu
Fri Aug 12 13:28:39 PDT 2011
On 08/12/2011 03:13 PM, bearophile wrote:
> Ellery Newcomer:
>> in std.container, the stable* container functions advocate that they do
>> not invalidate the ranges of their containers. What does it mean to
>> invalidate a range?
> Generally modifying a collection while you iterate on it causes troubles. When you iterate on a range and you modify the range during the iteration Python gives you an error, because the "for" temporary sets boolean inside the iteratee. In D this problem was avoided in another way, using those stable functions.
I am not convinced of this. In the following code, there is definitely a
problem; it just remains to be seen whether the range is invalidated, or
merely noisy according to the specified semantics.
auto arr = make!(Array!int)([1,2,3]);
auto r = arr;
More information about the Digitalmars-d-learn