Hi,

On 23/08/2013 19:36, Graydon Hoare wrote:
Could you say more (perhaps more constructively)? I believe we have
every intention to support these sorts of overloads longer-term; we
removed the previous support only because it wasn't done terribly well.
I think augmented assignments in Python are fine, but they do have some edge cases. The most famous one (as this is generally brought up as Python WTF on various parts of the interwebs) is the one where a mutable element within an immutable structure is modified:

>>> a = ([42],)
>>> a[0] += [23]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
>>> a
([42, 23],)

The reason for this is that `a[0] += [23]` expands to `type(a[0]).__iadd__(a[0], [23])` but afterwards a[0] is overridden with a[0].

Aside from that I believe += and friends are just fine. Some people raised concern that `a = a + [2]` makes a new list but `a += [2]` modifies a list in place, but I think that is pretty obvious from looking at the code.


Regards,
Armin
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to