Object-oriented units of measurement

Programs that manipulate physical quantities typically represent these quantities as raw numbers corresponding to the quantities' measurements in particular units (e.g., a length represented as a number of meters). This approach eliminates the possibility of catching errors resulting from adding or comparing quantities expressed in different units (as in the Mars Climate Orbiter error [11]), and does not support the safe comparison and addition of quantities of the same dimension. We show how to formulate dimensions and units as classes in a nominally typed object-oriented language through the use of statically typed metaclasses. Our formulation allows both parametric and inheritance poly-morphism with respect to both dimension and unit types. It also allows for integration of encapsulated measurement systems, dynamic conversion factors, declarations of scales (including nonlinear scales) with defined zeros, and nonconstant exponents on dimension types. We also show how to encapsulate most of the "magic machinery" that handles the algebraic nature of dimensions and units in a single meta-class that allows us to treat select static types as generators of a free abelian group.

[1]  Robert Cartwright,et al.  Efficient Implementation of Run-time Generic Types for Java , 2002, Generic Programming.

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

[3]  Andrew Kennedy,et al.  Relational parametricity and units of measure , 1997, POPL '97.

[4]  Adele Goldberg,et al.  SmallTalk 80: The Language , 1989 .

[5]  William S. Brown Applied template metaprogramming in siunits: the library of unit-based computation , 2001 .

[6]  Christopher A. Welty,et al.  What's in an Instance? , 1994 .

[7]  Robert Cartwright,et al.  A first-class approach to genericity , 2003, OOPSLA '03.

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

[9]  Narain H. Gehani Databases and Units of Measure , 1982, IEEE Transactions on Software Engineering.

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

[11]  Martin Odersky,et al.  Type Inference with Constrained Types , 1999, Theory Pract. Object Syst..

[12]  Geoff Baldwin Implementation of physical units , 1987, SIGP.

[13]  Ronald T. House A Proposal for an Extended Form of Type Checking of Expressions , 1983, Comput. J..

[14]  R. Männer,et al.  Strong typing and physical units , 1986, SIGP.

[15]  Ralph Johnson,et al.  design patterns elements of reusable object oriented software , 2019 .

[16]  André van Delft A Java Extension with Support for Dimensions , 1999, Softw. Pract. Exp..

[17]  Robert Cartwright,et al.  Compatible genericity with run-time types for the Java programming language , 1998, OOPSLA '98.

[18]  Michiel Korthals,et al.  Inf'erence d'unit'es physiques en ML , 1994 .

[19]  Andrew John Kennedy,et al.  Programming languages and dimensions , 1995 .

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

[21]  André Van Delft A Java extension with support for dimensions , 1999 .

[22]  Gilad Bracha,et al.  Strongtalk: typechecking Smalltalk in a production environment , 1993, OOPSLA '93.

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

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

[25]  Mitchell Wand,et al.  Automatic Dimensional Inference , 1991, Computational Logic - Essays in Honor of Alan Robinson.

[26]  Narain H. Gehani Ada's derived types and units of measure , 1985, Softw. Pract. Exp..