Hi,
I was looking at "extends" for extending derived types in the F2k draft.
In particular, the quote "An extended type is an extension of itself and
of all types for which its parent type is an extension".
The philosophy is similar to extending modules with USE statements, except
that with derived types we are limited to one parent. Is this one-parent
limitation necessary and/or difficult to relax?
For example, the following is allowed:
type point
real :: x,y
end type point
type, extends(point) :: colour_point
integer(3) :: RGB
end type colour_point
A more useful style (at least for me) would be:
type point
real :: x,y
end type point
type colour
integer(3) :: RGB
end type colour
type, extends(point,colour) :: colour_point
end type colour_point
so that procedures bound to the point and colour types would all get
inherited to the colour_point type. The parent types would be accessible
through their type names as it is now with the sole parent. With this
approach we would have to be more careful with name clashes (draft note
4.53), but that is no different to what we already have with modules. It
may or may not be a problem if the point and colour types were extensions
of the same parent type, I don't know....
Any thoughts?
Thanks,
Daniel.
------------------------------------------------------------------------
Dr. Daniel Grimwood Department of Chemistry
Email : [log in to unmask] The University of Western Australia
Phone : +61 8 93808563 35 Stirling Highway
Fax : +61 8 93801005 Crawley WA 6009
|