Affiliation:
1. Sun Microsystems Laboratories, Burlington, MA
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.
Publisher
Association for Computing Machinery (ACM)
Subject
Computer Graphics and Computer-Aided Design,Software
Cited by
22 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. CoSense: Compiler Optimizations using Sensor Technical Specifications;Proceedings of the 33rd ACM SIGPLAN International Conference on Compiler Construction;2024-02-17
2. Pluggable Type Inference for Free;2023 38th IEEE/ACM International Conference on Automated Software Engineering (ASE);2023-09-11
3. Managing Quantities and Units of Measurement in Code Bases;Updates on Software Usability;2023-02-22
4. Towards a Theory of Conversion Relations for Prefixed Units of Measure;Relational and Algebraic Methods in Computer Science;2023
5. Acknowledging Implementation Trade-Offs When Developing with Units of Measurement;Communications in Computer and Information Science;2023