Why are shorthand operators not implemented for Measurement?

(Tim Gymnich) #1

I was wondering why there are no shorthand operators (like: +=, -=, ...) implemented for measurement. They should be relatively easy to implement.


What kind of operator are you referring to?

1 Like
(Tim Gymnich) #3

Operators like these: += / -= / ...


Are you referring to this Class?

1 Like
(Tim Gymnich) #5


(Tony Parker) #6

When we originally proposed the feature, the compiler team was worried about adding hundreds of operator overloads for compile performance reasons. Each one adds a new possible resolution, and my understanding is that the algorithm for finding the right one does not scale linearly.

1 Like
(Ben Cohen) #7

While typechecker performance is a very valid concern, I suspect the main issues found in practice are with + more than += so holding off on those in particular probably isn’t critical (@xedin?) . And given these are resilient non-trivial types, possibly more important as performance tweaks than as just shorthand.

(Pavel Yaskevich) #8

+= is definitely less problematic based on the limited chaining ability, which is the biggest problem associated with +, so it's safer to overload comparing to other operators but if right-hand side is complex it could still create problems.