mp-units icon indicating copy to clipboard operation
mp-units copied to clipboard

Ordering and simplification of expression templates

Open mpusz opened this issue 8 months ago • 7 comments

Expression templates are simplified with the rules described in our docs.

For units and dimensions, ordering is being done based on the symbol of this entity. This provides nice outputs (i.e. N m). However, the rest of the steps are being done based on the same type identifier (elements with the same type are simplified). This might be considered an inconsistent approach. It is possible to do the ordering of dimensions and units based on their type identifiers as this is what we do for quantity_spec, which does not expose a symbol. This could, however, result in worse-quality text outputs.

Please see the following example: https://godbolt.org/z/c4eW7c6nK.

In case the ordering was done by the identifiers, most of the outputs would look like s m s there, or in case of "newton metre" we would get m N. But maybe, this is the price that we should pay for consistency? Also, I assume that it is not surprising that aggregation is not done for "the same" units with a different type?

Please let me know your thoughts, and let's decide how to proceed.

mpusz avatar Oct 09 '23 15:10 mpusz