[J3] [EXTERNAL] Elemental type-bound functions not useful
Van Snyder
van.snyder at sbcglobal.net
Tue Mar 30 01:09:41 UTC 2021
On Mon, 2021-03-29 at 20:34 -0400, Vipul Parekh wrote:
> For the use case mentioned by Van here involving ELEMENTAL operations
> of the type 'A = B + C', I personally think the code design should
> have the objects 'A", ''B', 'C' as all nonpolymorphic - they can be
> ALLOCATABLE/POINTER - but they can all be of the same dynamic type
> that is an extension of an ABSTRACT derived type but which is itself
> inextensible.
Fortran doesn't yet have "sealed" or "inextensible" types (unless I
missed something that prevents creating an extension type).
Making all the type-bound functions NON_OVERRIDABLE isn't really a
solution, because that just means that the functions in the base type
are used for operations on the extension type. That might actually be
worse than doing operations on the extension type, and producing a
result of the base type.
Having gone through three potential solutions in a previous message, I
think the best (although not complete) solution is to allow CLASSOF for
a non-allocatable non-pointer function result, provided the <data-ref>
in its CLASSOF declaration refers to a polymorphic dummy argument. When
the function is bound to a type, the <data-ref> in the CLASSOF
declaration has to refer to the passed-object dummy argument.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20210329/81ca73df/attachment.htm>
More information about the J3
mailing list