Measured - Type-safe, intuitive units of measure

There’s already a perfectly good standard for conversion functions: .toXxx(). Everything else uses it; it’s universally understood, very clear, and reads well.

So why does this project do something different, something that (judging from this thread) causes some confusion, as well as awkward syntax (backticks)? Why is this any different from converting a Long to an Int, a List to a Set, or a DateTime to an Instant?

IMHO, infix functions and operator overloads are best used sparingly, only where there’s a clear reason not to do things the ordinary way, where the intent is crystal clear and matches any existing usage. This doesn’t seem to be one of those situations.

as seems a particularly bad choice, as it usually means something different: .asXxx() functions create a view of an existing object, one which reflects changes to that object (and whose changes are applied back to it). Your use looks like that, but behaves differently, which could lead to subtle bugs.

1 Like