logo       

Re: Support for Indexing and Iteration Safety: msg#00348

python.c++

Subject: Re: Support for Indexing and Iteration Safety

> >>> x = foo[10].bar
> >>> del foo[10] # erase the 10th item
> >>> print x

What about having x a weak reference which del will reset to None.

> >>> x = foo[10]
> >>> foo[10] = y
> >>> print x, y
>
> Now you'll see that x and y are always identical, because x
> refers to the place in the array where you've written the
> value of y.

It's ok, because Python have explicit copy semantics
The list isn't the only model.

> 4. Similar problem with exposed iterators:
> change out from under you. The above could lead to a crash
> or bogus results.

bogus results are ok because it's the same as in Python - changing a list
under loop can lead to skiping an element or visiting it twice.

> know how many people care.

I think if it will put some restriction on usage it is ok with me.

Mike


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise