A Discipline of Programming with Quantities

In scientific and engineering applications, physical quantities embodied as units of measurement (UoM) are frequently used. The loss of the Mars climate orbiter, attributed to a confusion between the metric and imperial unit systems, popularised the disastrous consequences of incorrectly handling measurement values. Dimensional analysis can be used to ensure expressions containing annotated values are evaluated correctly. This has led to the development of a large number of libraries, languages and validators to ensure developers can specify and verify UoM information in their designs and codes. Many tools can also automatically convert values between commensurable UoM, such as yards and metres. However these systems do not differentiate between quantities and dimensions. For instance torque and work, which share the same UoM, can not be interchanged because they do not represent the same entity. We present a named quantity layer that complements dimensional analysis by ensuring that values of different quantities are safely managed. Our technique is a mixture of analysis and discipline, where expressions involving multiplications are relegated to functions, in order to ensure that named quantities are handled soundly.

[1]  Digital Representation of Units of Measurement , 2022, Chemistry International.

[2]  R. Hanisch,et al.  Stop squandering data: make units of measurement machine-readable , 2022, Nature.

[3]  Werner Dietl,et al.  Precise inference of expressive units of measurement types , 2020, Proc. ACM Program. Lang..

[4]  Steve McKeever,et al.  Unit of measurement libraries, their popularity and suitability , 2020, Softw. Pract. Exp..

[5]  Steve McKeever,et al.  Lack of Adoption of Units of Measurement Libraries: Survey and Anecdotes , 2020, 2020 IEEE/ACM 42nd International Conference on Software Engineering: Software Engineering in Practice (ICSE-SEIP).

[6]  B. D. Hall,et al.  Software for calculation with physical quantities , 2020, 2020 IEEE International Workshop on Metrology for Industry 4.0 & IoT.

[7]  Steve McKeever,et al.  The next 700 unit of measurement checkers , 2018, SLE.

[8]  Sebastian G. Elbaum,et al.  Assessing the Type Annotation Burden , 2018, 2018 33rd IEEE/ACM International Conference on Automated Software Engineering (ASE).

[9]  Marcus P. Foster,et al.  Physical-type correctness in scientific Python , 2018, ArXiv.

[10]  Sebastian G. Elbaum,et al.  Dimensional inconsistencies in code and ROS messages: A study of 5.9M lines of code , 2017, 2017 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS).

[11]  Sebastian G. Elbaum,et al.  Lightweight detection of physical unit inconsistencies without program annotations , 2017, ISSTA.

[12]  Marcus P. Foster Quantities, units and computing , 2013, Comput. Stand. Interfaces.

[13]  Grigore Rosu,et al.  A Rewriting Logic Approach to Static Checking of Units of Measurement in C , 2012, RULE.

[14]  Kostadin Damevski,et al.  Expressing measurement units in interfaces for scientific component software , 2009, CBHPC '09.

[15]  Mircea Lungu,et al.  Towards reverse engineering software ecosystems , 2008, 2008 IEEE International Conference on Software Maintenance.

[16]  Jonathan Cooper,et al.  A model-driven approach to automatic conversion of physical units , 2008 .

[17]  Zhendong Su,et al.  Osprey: a practical type system for validating dimensional unit correctness of C programs , 2006, ICSE.

[18]  Matthias Felleisen,et al.  Validating the unit correctness of spreadsheet programs , 2004, Proceedings. 26th International Conference on Software Engineering.

[19]  Martin Fowler,et al.  Analysis patterns - reusable object models , 1996, Addison-Wesley series in object-oriented software engineering.

[20]  Andrew Kennedy,et al.  Dimension Types , 1994, ESOP.

[21]  Paul N. Hilfinger,et al.  An Ada package for dimensional analysis , 1988, TOPL.

[22]  A Dreiheller,et al.  Programming pascal with physical units , 1986, SIGP.

[23]  David B. Loveman,et al.  Incorporation of units into programming languages , 1978, CACM.

[24]  R. Coulon,et al.  Bureau international des Poids et Mesures , 1936, Nature.

[25]  S. McKeever Discerning Quantities from Units of Measurement , 2022, MODELSWARD.

[26]  B. Hall The Problem with 'Dimensionless Quantities' , 2022, MODELSWARD.

[27]  Steve McKeever,et al.  From Quantities in Software Models to Implementation , 2021, MODELSWARD.

[28]  Görkem Paçaci,et al.  Quantity Checking through Unit of Measurement Libraries, Current Status and Future Directions , 2019, MODELSWARD.

[29]  知秋 Microsoft:微软“变脸” , 2006 .

[30]  Narain H. Gehani,et al.  Units of Measure as a Data Attribute , 1977, Comput. Lang..