Technical Program
  Invited Speakers
  Technical Papers
  Practitioner Reports
Educators' Symposium
Doctoral Symposium
Student Research Comp.
Turing Lecture
Social Events
Week at a Glance
Final Program (1.5M .pdf)

Find in Program


view, help

"Object-Oriented Units of Measurement"
Object-Oriented Programming, Systems, Languages and Applications
Home    Program    Housing & Transportation    Registration    Submissions    Wiki    Maps
  > Technical Program > Technical Papers > Languages

 : Thursday

Object-Oriented Units of Measurement

Ballroom A-B
Thursday, 11:30, 30 minutes


Eric Allen, Sun Microsystems
David Chase, Sun Microsystems
Victor Luchangco, Sun Microsystems
Jan-Willem Maessen, Sun Microsystems
Guy Steele, Sun Microsystems

Programs that manipulate physical quantities typically represent these quantities as raw numbers corresponding to the quantities' measurement in a particular unit (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), and does not support \emph{dimensional analysis}, a powerful form of static checking on expressions of physical quantities. 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 polymorphism with respect to both dimension and unit types. It also allows for integration of encapsulated measurement systems, dynamic conversion factors, and declarations of scales (including nonlinear scales) with defined zeros, and nonconstant exponents on dimension types. Finally, we show how to encapsulate most of the "magic machinery" that handles the algebraic nature of dimensional units in a single metaclass that allows us to treat select static types as generators of a free abelian group.