Unitful.jl without parametrizing types on units?

I don’t do much for errors. The one thing I’d note is that instead of Unitful.DimensionError, I return the quantity as normal and set the (q::Quantity).valid flag to false. This is to remain consistent with the theme of type stability. That’s it though; it’s a pretty lightweight package: only ~300 SLOC.

(MethodError will still occur if a method is not defined for the Quantity type.)

This error return inspired by GitHub - JuliaPreludes/Try.jl: Zero-overhead and debuggable error handling. From the discussion on Performance of hasmethod vs try-catch on MethodError it seems like try-catch on a DimensionError is bound to be slower than tracking an extra value for errors in calculation.