(j3.2006) Function returning procedure pointers
Malcolm Cohen
malcolm
Thu Dec 25 01:07:45 EST 2014
Hi folks,
Why did we pass an interp to make these happen? They are really horrible, and
violate our usual design rule of encapsulating things in derived types when
building bigger things - whereas with these one can have a pointer to a function
returning a pointer to a function returning a pointer to a function ...
(unbounded recursion).
It's not that it's impossible to implement, but it's really horrid. Does anyone
accept the following yet?
Module junk
Contains
Character(2) Function f0()
f0 = 'ok'
End Function
Function f1()
Procedure(f0),Pointer :: f1
f1 => f0
End Function
Function f2()
Procedure(f1),Pointer :: f2
f2 => f1
End Function
Function f3()
Procedure(f2),Pointer :: f3
f3 => f2
End Function
Function f4()
Procedure(f3),Pointer :: f4
f4 => f3
End Function
End Module
Program test
Use junk
Procedure(f0),Pointer :: p0
Procedure(f1),Pointer :: p1
Procedure(f2),Pointer :: p2
Procedure(f3),Pointer :: p3
Procedure(f4),Pointer :: p4
p4 => f4
p3 => p4()
p2 => p3()
p1 => p2()
p0 => p1()
Print *,p0()
End Program
Luckily we don't have to handle p4()()()()(). Yet.
Cheers,
--
................................Malcolm Cohen, Nihon NAG, Tokyo.
More information about the J3
mailing list