Hacker News new | ask | show | jobs
by ahupp 914 days ago
IMO using operator overloading for this kind of thing makes it hard to read, since I have to be extra careful to mentally parse whether that `*` is a multiplication or units, remember what variables are in scope etc. Notation matters, and if I didn't care about that I'd just write `pint.Quantity(5, "meters/second")` and be done with it. Or more likely, not go to the trouble of using them at all.

> I don’t understand why you’d go to the enormous trouble

But more importantly, it was just really fun to get it working.

1 comments

> IMO using operator overloading for this kind of thing makes it hard to read, since I have to be extra careful to mentally parse whether that `*` is a multiplication or units

Units are inherently exactly multiplication.

5 meters is:

5 (unitless) * (1) meter

Yes. There are many (infinitely!) ways to write an equivalent expression, most of which are not as clear to read as the standard format.