[J3] Can a type-bound procedure be passed as an actual argument

Daniel C Chen cdchen at ca.ibm.com
Wed Jan 11 18:07:57 UTC 2023


Hi All,
Consider the following code

Case 1:
  type dt
   contains
    procedure, nopass :: foo => real_foo
  end type
  interface
    subroutine real_foo()
    end
  end interface
  type(dt) :: t1
  call sub1(t1%foo)    !!! Is it legal to pass t1%foo as actual argument?
end

Case 2:
module m
  type dt
   contains
    procedure :: foo => real_foo
  end type
contains
    subroutine real_foo(this)
      class(dt) :: this
    end
end

program main
use m
  type(dt) :: t1
  call sub1(t1%foo)   !!! Is it legal to pass t1%foo as actual argument?

end

I couldn't find any wording in the standard (F2018) that prohibits the two usages above, and yet a couple of compilers that I have access to flags error message.

Thanks,
Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20230111/a6c62c5e/attachment.htm>


More information about the J3 mailing list