Summary
This chapter considers various aspects of how an Ada program interfaces to the outside world. One area is the mapping of the abstract Ada program onto the computer; how the data structures are represented and so on. Another important aspect is communication with programs in other languages. (Communication with the outside world through interrupts is dealt with in Section 26.1.) However, the discussion in this chapter cannot be exhaustive because many details of this area will depend upon the implementation. The intent, therefore, is to give the reader a general overview of the facilities available.
Representations
When compiling a program, the compiler needs to decide how the various data items are to be represented. Certain uses or occurrences of entities require that their representation be known; such occurrences are called freezing points. We can provide explicit information about certain aspects of an entity and that of course determines that aspect. If no such information is provided then the compiler has to make some default decision at the first freezing point.
An obvious example is that declaring an object requires that its type be frozen. This does not apply to deferred constants since in the case of private types the freezing is deferred until the full type declaration. If we wish to provide our own representation then this must be done before the entity is otherwise frozen. Note that the end of a declarative part freezes all the items declared in it anyway (except for incomplete types) and so any representation information must be in the same declarative part as the entity to which it applies.
In most cases the freezing rules are very much a fringe aspect of the language and intuitively obvious and have little impact on the normal programmer. One important interaction with other rules was however noted in Section 14.6 when we discussed type extension and primitive operations. We noted that we cannot add further primitive operations after a tagged type is frozen and moreover that a tagged type is frozen when a type is derived from it.
In summary, a type must be fully defined, including all aspect clauses and dispatching operations, before it is frozen. Declaring an object of a type or extending a type freezes it.
We can provide our own representations using aspect clauses which can take various forms or (in Ada 2012) in most cases by using aspect specifications.
- Type
- Chapter
- Information
- Programming in Ada 2012 , pp. 781 - 802Publisher: Cambridge University PressPrint publication year: 2014