Ada's derived types and units of measure
- 1 June 1985
- journal article
- Published by Wiley in Software: Practice and Experience
- Vol. 15 (6) , 555-569
- https://doi.org/10.1002/spe.4380150604
Abstract
Types in programming languages cannot model many properties of real world objects and quantities. Consequently, many errors resulting from the inconsistent usage of program objects representing real world objects and quantities cannot be detected automatically. For example, the real variables PRICE and WEIGHT, representing the price of diesel fuel and the weight of a person, may be inadvertently added, giving a non‐sensical value; such an error cannot be detected by a compiler. The programming language Ada introduces the concept ofderivedtypes to tackle this problem. An alternative solution to this problem is the incorporation ofunits of measureas a new data attribute. Derived types only partially solve the problem of detecting the inconsistent usage of objects; some valid usages of objects are also not allowed. Moreover, the solution is inelegant and inconvenient to use. On the other hand, specification of units of measure solves the problem elegantly and conveniently. The two solutions are compared and analysed. Several ways to implement units of measure in Ada are examined.Keywords
This publication has 6 references indexed in Scilit:
- Databases and Units of MeasureIEEE Transactions on Software Engineering, 1982
- Rationale for the design of the Ada programming languageACM SIGPLAN Notices, 1979
- DoD-IACM SIGPLAN Notices, 1978
- Incorporation of units into programming languagesCommunications of the ACM, 1978
- Units of measure as a data attributeComputer Languages, 1977
- Types are not setsPublished by Association for Computing Machinery (ACM) ,1973