[J3] Elemental type-bound functions not useful

Van Snyder van.snyder at sbcglobal.net
Sun Mar 28 23:11:16 UTC 2021


The passed-object dummy argument of a type-bound function has to be
polymorphic. The result of an elemental function cannot be polymorphic,
because it cannot be allocatable or a pointer. This makes elemental
type-bound functions not really useful because in a type extension, the
result of the type-bound function is still of the declared type.

Did I miss something that makes them useful?

Is there something that can be done to make them useful?

When OO was being developed, there were proposals for CLASSOF and
TYPEOF declarations, to specify that some entity had the same class or
type as another. Those proposals failed. Could something like that make
type-bound elemental functions useful?

Is it absolutely necessary for a passed-object dummy argument to be
polymorphic? An alternative is to require that one that does not have a
polymorphic passed-object dummy argument is overridden in extensions.

An onerous alternative is to require that type-bound elemental
functions that have the same result type as the declared type are
overridden in every extension. Ugh. Users should do this, but what a
burden!

Another onerous alternative is for users to provide a non-elemental
function for every rank. It was precisely to avoid this that elemental
functions were invented.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20210328/509b991f/attachment.htm>


More information about the J3 mailing list