Un-typed arguments

This proposal follows on from the discussion of generics.

There are situations where the type, kind and shape of an argument may be irrelevant. For example, when calling a wrapper for an mpi routine which sends a packet of data, or when detecting whether anything has changed anywhere in a data structure.

When routines with arguments like this are contained in modules, they may need to be written as generics with specific routines for all of the different possible data types of the arguments.

What is proposed is that we have an intrinsic data type called VARIANT, with kinds corresponding
to the INTEGER kinds, so that an argument could be written:

SUBROUTINE send(q)
    VARIANT(1) :: q(2048)   ! q is 2048 bytes long
    < post q through the network >
END SUBROUTINE send

And the compiler doesn’t worry about what is in q in any particular call. Then we don’t need
multiple specific routines for send.

Has this been suggested before? I suspect it has.

1 Like

Isn’t it a use case of type(*) ?

2 Likes