[J3] Can a procedure pointer have character(*) result type?

Vipul Parekh parekhvs at gmail.com
Tue Nov 29 20:01:09 UTC 2022

On Tue, Nov 29, 2022 at 2:10 PM Daniel C Chen via J3 <
j3 at mailman.j3-fortran.org> wrote:

> Consider the following example:
> ..
> subroutine sub(proc, arg)
> character(*) :: arg
> !character(*) :: proc                      !! This is OK
> character(*), external, pointer :: proc    !! Question: is this conforming?
> print*, proc(arg)
> end

Hi Daniel,

Based on a quick glance at the standard, I think it still supports "Assumed
character length functions" though it has marked them as obsolescent.  See
B.3.6 in 22-007 (WG5 N191, Dec. 2021) document.  That's what you have with "
character(*) result type" and toward which the standard notes, "Assumed
character length for functions is an irregularity in the language in that
elsewhere in Fortran the philosophy is that the attributes of a function
result depend only on the actual arguments of the invocation and on any
data accessible by the function through host or use association."

Separately the `proc` received argument in your `sub` method has also the
`POINTER` attribute.  However your caller main program does not have an
explicit interface for `sub`'  So your main program does not conform.

Best Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20221129/061530fb/attachment.htm>

More information about the J3 mailing list