6.2 Tagged types.
In a number of places in the text so far we have made mention of tagged types, a feature added in Ada95 to provide for object oriented programming. Tagged types are an extension to the existing concept of a record, and provide the run-time information required to make dispatching calls to primitive operations (virtual functions) therefore providing polymorphism. They also provide a method for extending a type when deriving it and so complete our C++ class feature list above.
You have now seen a tagged type declaration, please note the following additional features:
The above is a simple form of the package body for the package Animal.
Note: in the above package the main type is called Instance, this is a common convention which does have some advantages. Mainly it uses the package/type relationship and the namespace management of Ada to provide meaningful names. Other conventions are to use plurals for package names and use the singular for the type, for instance:
package Animals is type Animal is tagged .. .. An_Animal : Animal; A_Dog : Animals.Dogs.Dog;
Copyright ©
1996 Simon Johnston &
Addison Wesley Longman