4 ms·
> I'd argue the first one is not a smaller WTF than the latter. I think the first one probably arises more frequently, but at least there's a fairly straightfo
by pansa2 1y ago
> I'd argue the first one is not a smaller WTF than the latter.
I think the first one probably arises more frequently, but at least there's a fairly straightforward explanation: "`x += y` acts in-place if-and-only-if `x` is mutable".
The second example is more niche but it's much harder to explain what's going on - it can only be understood by first understanding the first example, and what it implies about the implementation of `+=`.
- zahlman 1y ago> but at least there's a fairly straightforward explanation: "`x += y` acts in-place if-and-only-if `x` is mutable". This is the explanation. By definition it is only possible when the left-hand side is mutable; and in these cases, it's also typically convenient. This was apparently seen as "although practicality beats purity" rather than "special cases aren't special enough to break the rules".