(j3.2006) Invoking type-bound function using the result of another one

Van Snyder Van.Snyder
Thu Jan 7 21:59:11 EST 2016


Given:

Types T1 and T2 with type-bound functions F1 and F2, respectively.

F1 and F2 have arguments of class T1 and T2 respectively.

F1 and F2 are also accessible on their own.

F1 has a result of type T2.

X1 is a variable of type T1.

Then I can invoke f2(f1(x1)), but I cannot invoke x1%f1()%f2(), i.e.,
type-bound function composition is prohibited.

Other than our traditional aversion to selecting components of function
results, or more generally to selecting components of expression values,
was there a technical reason to prohibit this?

module M

  type T1
  contains
    procedure :: F1
  end type T1

  type T2
  contains
    procedure :: F2
  end type T2

contains

  type(t2) function F1 ( A )
    class(t1), intent(in) :: A
    ...
  end funciton F1

  real function F2 ( A )
    class(t2), intent(in) :: A
    ...
  end function H2

end module M

program P

  use M
  type(t1) :: X1
  print *, f2(f1(x1))
! print *, x1%f1()%f2()        ! Prohibited (why?)

end program P





More information about the J3 mailing list