Object-oriented units of measurement
2004, ACM SIGPLAN Notices
https://doi.org/10.1145/1035292.1029008Abstract
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 encap...
References (30)
- REFERENCES
- E. Allen, J. Bannet, and R. Cartwright. A First-Class Approach to Genericity. In Proceedings of the Eighteenth Annual SIGPLAN Conference on Object-Oriented Systems, Languages, and Applications, Anaheim CA 2003.
- E. Allen, R. Cartwright, and B. Stoler. Efficient implementation of run-time generic types for Java. In IFIP WG2.1 Working Conference on Generic Programming, 2002.
- G. Baldwin. Implementation of Physical Units. SIGPLAN Notices, V. 22(8). August 1987.
- G. Bracha, D. Griswold. Strongtalk: Typechecking Smalltalk in a production environment. In Proceedings of the Eighth Annual SIGPLAN Conference on Object-Oriented Programming, Systems, Languages and Applications, pages 215-230, 1993.
- W. Brown. Applied Template Metaprogramming in SIUnits: the Library of Unit-Based Computation. In Proceedings of the Second Workshop on C++ Template Programming, October 2001. Available at http://www.oonumerics.org/tmpw01/brown.pdf.
- R. Cartwright and G. Steele. Compatible genericity with run-time types for the Java programming language. In Proceedings of the Thirteenth Annual SIGPLAN Conference on Object-Oriented Systems, Languages, and Applications, Vancouver BC 1998.
- J.C. Cleaveland. Redundant Specification in Programming Languages Through Pouches. UCLA Technical Report. 1975.
- A. Dreiheller, M. Moerschbacher, B. Mohr. PHYSCAL: Programming Pascal with Physical Units. SIGPLAN Notices, V. 21(12), December 1986.
- D. Ferrucci, C. Welty. What's in an Instance? RPI Computer Science Technical Report. 1994.
- M. Fowler. Analysis Patterns: Reusable Object Models. Addison-Wesley 1997.
- D. Isbell, D. Savage. Mars Climate Orbiter Failure Board Releases Report, Numerous NASA Actions Underway in Response. NASA Press Release 99-134. http://nssdc.gsfc.nasa.gov/planetary/text/ mco pr 19991110.txt. Nov. 10, 1999.
- E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, 1995.
- N. Gehani. Units of Measure as a Data Attribute. Computer Languages, Vol. 2. pp. 93-111. Pergamon Press, 1977. Printed in Great Britain.
- N. Gehani. Databases and Units of Measure. IEEE Transactions on Software Engineering. Vol. SE-8, No. 6, November 1982.
- N. Gehani. Ada's Derived Types and Units of Measure. Software -Practice and Experience, Vol. 15(6), 555-569. June 1985.
- J. Goubault. Inference d'unites physiques en ML. In P. Cointe, C. Queinnec, and B. Serpette, editors, Journees Francophones des Langages Applicatifs, Noirmoutier, p.3-20. INRIA, Collection didactique, 1994.
- P. Hilfinger. An Ada Package for Dimensional Analysis. ACM Transactions on Programming Languages and Systems, Vol. 10, No. 2, April 1988. p. 189-203.
- R. T. House. A Proposal for an Extended Form of Type Checking of Expressions. The Computer Journal, Vol. 26, No. 4. 1983.
- M. Karr, D. B. Loveman III. Incorporation of units into programming languages. Communications of the ACM, 21(5):385-391, May 1978.
- A. Kennedy. Dimension Types. In Proceedings of the 5th European Symposium on Programming Languages and Systems. Edinburgh, U.K. 1994.
- A. Kennedy. Programming Languages and Dimensions. PhD Thesis. St. Catharine's College. November 1995.
- A. Kennedy. Relational Parametricity and Units and Measure. In Proceedings of the 24th Annual ACM Symposium on Principles of Programming Languages, Paris, France. January 1997.
- R. Manner. Strong Typing and Physical Units. SIGPLAN Notices V. 21(3), March 1986.
- P. Neumann. Risks to the public from the use of computers. ACM Software Engineering Notes, 10(3) July 1985.
- M. Sulzmann, The Chameleon website. http://www.comp.nus.edu.sg/ sulzmann/chameleon/
- M. Sulzmann, M. Odersky, M. Wehr, Type Inference with Constrained Types. Theory and Practice of Object Systems, 5(1), 1999.
- A. van Delft. A Java Extension with Support for Dimensions. Software -Practice and Experience, 29(7), 605-616. 1999.
- M. Wand, P. M. O'Keefe. Automatic dimensional inference. In J.-L. Lassez and G. Plotkin, editors, Computational Logic: Essays in Honor of Alan Robinson. MIT Press, 1991.
- A. Goldberg, D. Robson. Smalltalk-80: The Language. Addison-Wesley, 1989.