4. Types and Attributes

[ Table of Contents ] Prev ] Next ] [ Glossary/Index ]

This chapter covers Ada's type system, its built-in attributes, and the issue of type conversion (known as casting in C++).

Chapter Contents

Ada is a "strongly typed" language. Every object has a clearly defined set of values and legal operations, typically defined in a type declaration. Most objects are instances of a named type (except for one-of-a-kind arrays, tasks, and protected objects, whose legal values and operations are clearly defined in the object declarations). Ada does not generally allow implicit conversions (as allowed in other languages such as C, C++, Fortran and Pascal). Conversions are generally programmed as explicit conversions. (Some implicit conversions occur in operations with numeric quantities. Other implicit type conversions occur in the case of dispatching operations -- see next chapter on OOP.)

Here is a relevant quote from [Barnes96]. "Values of one type cannot be assigned to variables of another type. This is the fundamental rule of strong typing. Strong typing, correctly used, is an enormous aid to the rapid development of correct programs since it ensures that many errors are detected at compile time."

[ Back to top of page ] [ continue ]