Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
article

Object-oriented units of measurement

Published: 01 October 2004 Publication History

Abstract

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.

References

[1]
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.
[2]
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.
[3]
G. Baldwin. Implementation of Physical Units. SIGPLAN Notices, V. 22(8). August 1987.
[4]
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.
[5]
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.
[6]
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.
[7]
J.C. Cleaveland. Redundant Specification in Programming Languages Through Pouches. UCLA Technical Report. 1975.
[8]
A. Dreiheller, M. Moerschbacher, B. Mohr. PHYSCAL: Programming Pascal with Physical Units. SIGPLAN Notices, V. 21(12), December 1986.
[9]
D. Ferrucci, C. Welty. What's in an Instance? RPI Computer Science Technical Report. 1994.
[10]
M. Fowler. Analysis Patterns: Reusable Object Models. Addison-Wesley 1997.
[11]
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.
[12]
E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, 1995.
[13]
N. Gehani. Units of Measure as a Data Attribute. Computer Languages, Vol. 2. pp. 93--111. Pergamon Press, 1977. Printed in Great Britain.
[14]
N. Gehani. Databases and Units of Measure. IEEE Transactions on Software Engineering. Vol. SE-8, No. 6, November 1982.
[15]
N. Gehani. Ada's Derived Types and Units of Measure. Software - Practice and Experience, Vol. 15(6), 555--569. June 1985.
[16]
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.
[17]
P. Hilfinger. An Ada Package for Dimensional Analysis. ACM Transactions on Programming Languages and Systems, Vol. 10, No. 2, April 1988. p. 189--203.
[18]
R. T. House. A Proposal for an Extended Form of Type Checking of Expressions. The Computer Journal, Vol. 26, No. 4. 1983.
[19]
M. Karr, D. B. Loveman III. Incorporation of units into programming languages. Communications of the ACM, 21(5):385--391, May 1978.
[20]
A. Kennedy. Dimension Types. In Proceedings of the 5th European Symposium on Programming Languages and Systems. Edinburgh, U.K. 1994.
[21]
A. Kennedy. Programming Languages and Dimensions. PhD Thesis. St. Catharine's College. November 1995.
[22]
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.
[23]
R. Manner. Strong Typing and Physical Units. SIGPLAN Notices V. 21(3), March 1986.
[24]
P. Neumann. Risks to the public from the use of computers. ACM Software Engineering Notes, 10(3) July 1985.
[25]
M. Sulzmann, The Chameleon website. http://www.comp.nus.edu.sg/ sulzmann/chameleon/
[26]
M. Sulzmann, M. Odersky, M. Wehr, Type Inference with Constrained Types. Theory and Practice of Object Systems, 5(1), 1999.
[27]
A. van Delft. A Java Extension with Support for Dimensions. Software - Practice and Experience, 29(7), 605--616. 1999.
[28]
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.
[29]
A. Goldberg, D. Robson. Smalltalk-80: The Language. Addison-Wesley, 1989.

Cited By

View all
  • (2023)Managing Quantities and Units of Measurement in Code BasesUpdates on Software Usability10.5772/intechopen.108014Online publication date: 22-Feb-2023
  • (2023)Acknowledging Implementation Trade-Offs When Developing with Units of MeasurementModel-Driven Engineering and Software Development10.1007/978-3-031-38821-7_2(25-47)Online publication date: 4-Aug-2023
  • (2023)Towards a Theory of Conversion Relations for Prefixed Units of MeasureRelational and Algebraic Methods in Computer Science10.1007/978-3-031-28083-2_16(258-273)Online publication date: 3-Apr-2023
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM SIGPLAN Notices
ACM SIGPLAN Notices  Volume 39, Issue 10
OOPSLA '04
October 2004
448 pages
ISSN:0362-1340
EISSN:1558-1160
DOI:10.1145/1035292
Issue’s Table of Contents
  • cover image ACM Conferences
    OOPSLA '04: Proceedings of the 19th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications
    October 2004
    462 pages
    ISBN:1581138318
    DOI:10.1145/1028976
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 01 October 2004
Published in SIGPLAN Volume 39, Issue 10

Check for updates

Qualifiers

  • Article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)22
  • Downloads (Last 6 weeks)0
Reflects downloads up to 23 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2023)Managing Quantities and Units of Measurement in Code BasesUpdates on Software Usability10.5772/intechopen.108014Online publication date: 22-Feb-2023
  • (2023)Acknowledging Implementation Trade-Offs When Developing with Units of MeasurementModel-Driven Engineering and Software Development10.1007/978-3-031-38821-7_2(25-47)Online publication date: 4-Aug-2023
  • (2023)Towards a Theory of Conversion Relations for Prefixed Units of MeasureRelational and Algebraic Methods in Computer Science10.1007/978-3-031-28083-2_16(258-273)Online publication date: 3-Apr-2023
  • (2017)Signals, Systems, and Design [Book review]Computing in Science and Engineering10.1109/MCSE.2017.315125119:4(72-73)Online publication date: 17-Aug-2017
  • (2017)Quantity Correctness in Fortran ProgramsComputing in Science and Engineering10.1109/MCSE.2017.315123719:4(83-87)Online publication date: 17-Aug-2017
  • (2015)HydroUnits: supporting dimensional analysis in hydrologic computing systems using sensor-based standardsJournal of Hydroinformatics10.2166/hydro.2015.07518:2(168-184)Online publication date: 4-Dec-2015
  • (2013)Quantities, units and computingComputer Standards & Interfaces10.1016/j.csi.2013.02.00135:5(529-535)Online publication date: Sep-2013
  • (2012)Automatic Dimensional Analysis of Cyber-Physical SystemsFM 2012: Formal Methods10.1007/978-3-642-32759-9_30(356-371)Online publication date: 2012
  • (2024)CoolerSpace: A Language for Physically Correct and Computationally Efficient Color ProgrammingProceedings of the ACM on Programming Languages10.1145/36897418:OOPSLA2(846-875)Online publication date: 8-Oct-2024
  • (2024)CoSense: Compiler Optimizations using Sensor Technical SpecificationsProceedings of the 33rd ACM SIGPLAN International Conference on Compiler Construction10.1145/3640537.3641576(73-85)Online publication date: 17-Feb-2024
  • Show More Cited By

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media