For example, often, one requires that instances of a derived type be
declared outside the Module in which the type is defined. But is also
usually required that the components of the type be invisible to the
outside. In such circumstances it is necessary that all procedures
that operate on this type be contained in the Module in which the
type is defined, thus leading to impractically large source files.
---------------------------------------------------------------
The following pseudo code in which the new constructs UMBRELLA
and UNDER are introduced is intended to illustrate my objectives.
In this scheme, the UMBRELLA becomes the unit of "Object Oriented" or
"logical" encapsulation and MODULES serve as a convenient means
of partitioning a system. However, there is nothing to stop Modules
being used in the same way that they are currently.
=== Pseudo code follows ===
! ... Define an UMBRELLA (MySystem) which USEs Modules
! which may be in different files. The entities within a
! Module which is UNDER MySystem are visible (PUBLIC) to
! all other entities within all other Modules which are
! also UNDER MySystem.
UMBRELLA MySystem
! ... This UMBELLA contains the declaration of the type MyType and
! and all the procedures which operate on it.
USE MyTypeModule
USE MyPublicModuleA
USE MyPublicModuleB
USE MyPrivateModuleA
USE MyPrivateModuleB
END UMBRELLA MySystem
MODULE MyTypeModule
! ... Declare that MyTypeModule is UNDER the MySystem UMBRELLA
UNDER MySystem
PUBLIC
! ... MyType is PUBLIC but its components are PRIVATE, except in
! those modules UNDER the MySystem UMBRELLA, where the
! components are PUBLIC.
TYPE :: MyType
PRIVATE
INTEGER :: componentA
...
END TYPE MyType
...
END MODULE MyTypeModule
... Similar for MyPrivateModuleB etc.
MODULE SomeOtherModule
USE MyTypeModule
USE MyPublicModuleA
CONTAINS
SUBROUTINE SomeSub(x)
TYPE(MyType) :: x
! ... The components of x cannot be accessed because
! SomeOtherModule is not UNDER MySystem.
! Similarly, PrivSubA can not be called from this Module.
! However, SubA can be called because it was declared
! to be PUBLIC in MyPublicModuleA.
CALL SubA(x)
END SUBROUTINE SomeSub
END MODULE SomeOtherModule
Just for your information, I proposed such a technical solution of dividing
large modules for defining Abstract Data Types in my book "Fortran 90 &
FortraN 95 - intensive computation and Software Engeeniring" (in french),
in chapter 12 ("complements methodologiques").
Sincerely yours,
---------------------------------------------------------
* Patrice LIGNELET *
* Tel: 01 40 27 23 83 Fax: 01 40 27 23 77 *
* 22 58 (Secretariat) *
* Courriel: [log in to unmask] *
* Sur la Toile mondiale (le Ouaibe): *
* http://www2.cnam.fr/~lignelet *
* *
* Conservatoire National des Arts et Metiers *
* Departement d'Informatique *
* 292, rue Saint Martin (\
* 75141 PARIS Cedex 03 ( \
=========================================================) ) />
/ ) / //))/
\ \_/ /////
\ /
\_ /
| |
| |
-----
-----
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|