(j3.2006) Invoking type-bound function using the result of another one
Tom Clune
Thomas.L.Clune
Fri Jan 8 08:46:27 EST 2016
Damian and I have also advocated that the constraints be weakened to somehow allow such chaining of methods. If there are technical reasons why that particular syntax won?t work, then it seems e could come up with something that is only slightly more verbose.
> On Jan 7, 2016, at 9:59 PM, Van Snyder <Van.Snyder at jpl.nasa.gov> wrote:
>
> 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
>
>
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3
Thomas Clune, Ph. D. <Thomas.L.Clune at nasa.gov>
Software Infrastructure Team Lead
Global Modeling and Assimilation Office, Code 610.1
NASA GSFC
MS 610.1 B33-C128
Greenbelt, MD 20771
301-286-4635
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20160108/06ea0a86/attachment-0003.html
More information about the J3
mailing list