2 ms·
> To me, a unary operator shouldn't mutate its receiver. Instead, the resulting value is meant to be assigned to a new value or otherwise manipulated. Why? And
by masklinn 16y ago
> To me, a unary operator shouldn't mutate its receiver. Instead, the resulting value is meant to be assigned to a new value or otherwise manipulated.
Why? And why would you draw that distinction for unary operators but not binary ones? Could it be just out of habit, because you've seen binary operators overloaded to mutate operands before but have never seen that with unary ones?
If the language implements unary operators as regular methods/messages (rather than special forms) why couldn't they be overloaded in the same way binary operators are, as long as it makes sense and reads correctly? (and in this case it certainly does)
- sid0 16y agoAnd why would you draw that distinction for unary operators but not binary ones? I wouldn't -- I think it's wrong for binary operators too.