Computing Reviews
Today's Issue Hot Topics Search Browse Recommended My Account Log In
Review Help
Search
An Ada package for dimensional analysis
Hilfinger P. ACM Transactions on Programming Languages and Systems10 (2):189-203,1988.Type:Article
Date Reviewed: Jul 1 1989

Dimensional analysis is a technique used to verify that numeric quantities are used in accordance with their units of measure (e.g., lengths should not be added to masses). This paper is essentially a response to a statement by O’Keefe about units of measure: “I am astounded that this long-standing idea [is absent from Ada], so much else of less potential benefit having been included” [1]. From past experience with the issue, Hilfinger felt that Ada could already provide such facilities through operator definition, operator overloading, and type parametrization. He wrote this paper “to explore the definitional capabilities of one modern, statically typed language as a means of language extension.”

The paper develops a “value-with-units” type for distances, masses, etc. This type is used to implement generic quantity subtypes (e.g., DISTANCE and VELOCITY), basic units of measure (e.g., METER, KG, and SEC), and conversions between commensurate units (e.g., FOOT = .3048 * METER and MPH = (5280 * FOOT) / (3600 * SEC). Operator overloading and type checking ensure the appropriate use of dimensions. This technique yields readable quantities expressed in a “natural” notation. The paper explains the package’s use, implementation, and potential efficiency. Hilfinger keeps the presentation simple, but the package clearly meets the paper’s basic objective: to illustrate the breadth of Ada’s facilities for abstraction and extension.

Although a fleshed-out implementation would support the practical needs of most users, the package does not provide seamless, general-purpose dimensional analysis. For example, users must select the meaning and scale for each of four fixed dimensions. Even if the package were expanded to seven dimensions, as the author suggests, it would still impose a predefined view of measurement that could not accommodate application-specific measurement units (color, pitch, brightness, money, and postal codes all might benefit from explicit conversion formulae and combination rules).

This package involves the general issue of inheritance (generic and specific behavior of groups of related objects), but the paper does not address this topic explicitly. Ada provides abstraction and encapsulation tools, but a general dimensional analysis solution would fall more naturally in the domain of an object-oriented system. Ada simply was not intended for what amounts to system-level extensibility.

This paper is a useful, if occasionally unclear, example of Ada facilities. Hilfinger shows that application-level dimensional analysis is practical. The solution does not feel elegant, however; its implementation details are not transparent to the user. This paper convinced me neither that the approach represents a general solution nor that many Ada users will choose to implement such a package, with its run-time consequences, to provide largely compile-time benefits. O’Keefe’s point still seems valid: Ada includes so many facilities that the omission of dimensional analysis is surprising.

Reviewer:  T. R. Hanson Review #: CR112730
1) O’Keefe, R. A.Alternatives to keyword parameters. ACM SIGPLAN Not. 20, 6 (June 1985), 26–32.
Bookmark and Share
 
Ada (D.3.2 ... )
 
 
Data Types And Structures (D.3.3 ... )
 
 
Extensible Languages (D.3.2 ... )
 
 
Modules, Packages (D.3.3 ... )
 
 
Optimization (D.3.4 ... )
 
Would you recommend this review?
yes
no
Other reviews under "Ada": Date
Ada programmer’s handbook
Gonzalez D. (ed), Benjamin-Cummings Publ. Co., Inc., Redwood City, CA, 1991. Type: Book (9780805325294)
Jul 1 1991
Ada
Gehani N. (ed), Silicon Press, Summit, NJ, 1991. Type: Book (9780929306087)
Jun 1 1992
Ada
Lynch B. (ed)  Ada,Dublin, Ireland,Jun 12-14, 1990,1990. Type: Whole Proceedings
Jun 1 1992
more...

E-Mail This Printer-Friendly
Send Your Comments
Contact Us
Reproduction in whole or in part without permission is prohibited.   Copyright 1999-2024 ThinkLoud®
Terms of Use
| Privacy Policy