Jack Scheible wrote:
>
> > You can write a program with specific routines to handle linked
> > lists of various types. A particular linked list operation (e.g.,
> > search and insert) can have a generic name that is used for all of
> > the linked lists that you have provided. Fortran will automatically
> > apply the generic operation to the linked list whose type
> > corresponds to the actual argument at each call. This is a pretty
> > straightforward combination of F90 generic procedures with standard
> > linked list techniques. Fortran 95 makes things a little bit simpler
> > with a few features such as default initialization of structures and
> > pointer initialization to NULL.
>
> Will I not _still_ have to rewrite each linked-list function for every
> type of data I want to put into a linked list? That would be a
> maintenance nightmare. Tell me there is a better way.
>
By using the TRANSFER workaround, you only have to write one complete
set of routines manipulating a linked list of the "neutral" data type.
For each additional data type, you have only to write data conversion
routines from and to the neutral data type. This is much shorter than
having to rewrite the whole linked list manipulation module. Generic
names may be attributed to the conversion routines.
It is true that direct support for "templates" or "genericity"
would be a welcome addition for the next Fortran standard (2002 ?),
since the need for this feature has been mentioned relatively
frequently.
It is now to the standards committees to judge of the merits of this
feature versus difficulty of implementation.
Regards,
Jean Vezina
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|