next up previous contents
Next: Data Hiding Up: Fortran 90 's Object Oriented Previous: Fortran 90 's Object Oriented

Data Abstraction

It is convenient to use objects which mirror the structure of the entities which they model. In Fortran 90 user derived types provide a certain degree of abstraction and the availability of pointers allows fairly complex data structures to be defined. Pointers are implemented in a different way to many languages and are considerably less flexible (but more efficient) than, say, pointers in C. As Fortran 90 pointers are strongly typed, their targets are limited but this leads to securer and faster code. Fortran 90 does not support enumerated types but these can be simulated in a (semantic extension) module without too much trouble.

Two main problems are the lack of parameterised derived types and the lack of subtypes.

Parameterised derived types are user-defined types where the individual type components have selectable kinds. The idea would be to define a `skeleton' type which could be supplied with KIND values in such a way that the individual components are declared with these KIND s. As currently defined, derived types can have kind values for the components but they are fixed, for example the following two types are totally separate:

    TYPE T1
     INTEGER(KIND=1) :: sun_zoom
     REAL(KIND=1)    :: spock
    END TYPE T1
    TYPE T2
     INTEGER(KIND=2) :: sun_zoom
     REAL(KIND=2)    :: spock
    END TYPE T2

If the kind selection could be deferred until object declaration then they could be considered to be parameterised.

Subtypes are, as their name suggests, a subclass of a parent type. A common example may be a positive integer type which has exactly the same properties as an intrinsic INTEGER type but with a restricted range. Subtypes are expensive to implement but provide range checking security.


next up previous contents
Next: Data Hiding Up: Fortran 90 's Object Oriented Previous: Fortran 90 's Object Oriented

Adam Marshall ©University of Liverpool, 1996
Fri Dec 6 15:03:35 GMT 1996
Not for commercial use.