OOPSLA '04

Program
Technical Program
  Invited Speakers
  Technical Papers
  Onward!
  Panels
  Practitioner Reports
  Tutorials
Workshops
DesignFest
Educators' Symposium
Demonstrations
Posters
Doctoral Symposium
Exhibits
Student Research Comp.
FlashBoF
 
Turing Lecture
 
Social Events
 
Week at a Glance
 
Final Program (1.5M .pdf)

Find in Program
 

Page
Printer-friendly

Basket
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
 


 
7·8·9·10·11·12·13·14·15·16·17·18·19·20·21

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.