Mathematica: Compile won't work with a Quantity with units

This page identifies a possible issue, concern, error, limitation, or bug!
Webel IT Australia promotes the amazing Mathematica tool and the powerful Wolfram Language and offers professional Mathematica services for computational computing and data analysis. Our Mathematica tips, issue tracking, and wishlist is offered here most constructively to help improve the tool and language and support the Mathematica user community.
DISCLAIMER: Wolfram Research does not officially endorse analysis by Webel IT Australia.
Icon class
icon_class
far fa-sticky-note
icon_class_computed
far fa-sticky-note
Note kind
Policy level
Keywords
Click on the image to view it full size

The example shows Compile failing with UnitConvert, but it also fails with anything that returns a Quantity, which is not very useful if you have a units-aware library. The only way to get around it is to pre-scale all Quantity arguments in a wrapper, delegate to a compiled function that does not use Quantity, and then scale the result on the way back out, which defeats the entire purpose.

This limitation is a great shame given how useful the MMA Quantity system is.

Relates to
Related notes
Related notes (backlinks)
Related snippets (extracts)
Visit also
Visit also (backlinks)