(j3.2006) a question on allowing internal procedures as procedure targets

Bill Long longb
Mon Nov 3 15:22:33 EST 2008



Jim Xia wrote:
>
> Is the following declaration legal?
>
>
> function externFn ()
>     interface
>         integer function proc ()
>         end function
>     end interface
>
>     procedure(proc), pointer :: externFn
>     integer i
>
>     read *, i
>     externFn => f
>
>     contains
>
>     integer function f ()
>         f = i
>     end function
> end function
>
>
> If it is legal, how would the value of i be defined. Consider the 
> following user code
>
> procedure(proc), pointer :: func
>
> func => externFn()

At this point, func is associated with f, and the variable i is 
undefined (since it is local to the function : 16.6.6:3(a) )
>
> print *, func()   !<-- what would this function return

Executing func() causes execution of f = i when i is undefined.  Error.

Cheers,
Bill

>
>
> If the declaration is illegal, can anyone point out where the standard 
> states so.
>
> Thanks
>
>
> Jim Xia
>
> RL Fortran Compiler Test
> IBM Toronto Lab at 8200 Warden Ave, Markham, On, L6G 1C7
> Phone (905) 413-3444  Tie-line 313-3444
> email: jimxia at ca.ibm.com
> D2/YF7/8200 /MKM
> ------------------------------------------------------------------------
>
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3
>   

-- 
Bill Long                                   longb at cray.com
Fortran Technical Support    &              voice: 651-605-9024
Bioinformatics Software Development         fax:   651-605-9142
Cray Inc., 1340 Mendota Heights Rd., Mendota Heights, MN, 55120

            




More information about the J3 mailing list