From johnreid@maths.anu.edu.au Wed Apr  1 03:56:39 1995
Received: from cain.anu.edu.au by dkuug.dk with SMTP id AA15203
  (5.65c8/IDA-1.4.4j for <SC22WG5@dkuug.dk>); Tue, 28 Mar 1995 09:56:56 +0200
Received: by cain.anu.edu.au id AA18530
  (5.65c/IDA-1.4.4 for SC22WG5@dkuug.dk); Tue, 28 Mar 1995 17:56:39 +1000
Date: Tue, 28 Mar 1995 17:56:39 +1000
From: "John.Reid" <John.Reid@maths.anu.edu.au>
Message-Id: <199503280756.AA18530@cain.anu.edu.au>
To: comp-fortran-90@mailbase.ac.uk
Subject: Pointers to procedures
Cc: SC22WG5@dkuug.dk
X-Charset: ASCII
X-Char-Esc: 29

I gave a talk on Fortran 90 here at ANU, which has provoked a finite-element
expert to ask why we do not have pointers to procedures in Fortran 90. What
he most needs is the ability to include procedures as structure components. 
It occurs to me that this could be done with the declaration of interfaces in
a type, as in the example:

      type problem
         interface 
           function a(x,y)
               real a,x,y
           end function a
           function b(x,y)
               real b,x,y
           end function b
         end interface 
      end type problem

A constructor could be used to associate the components with procedures:

      type(problem) p
      :
      p = problem(mya,myb)
      :
      call solve(p,...

or a pointer assignment statement could be used for individual components:

      p%a => mya
 
The rules about interface agreement could be as for dummy and actual
procedures in the presence of explicit interfaces. 

The effect of invoking the procedure through the component:

      d = p%a(x,y)

would be exactly as now for dummy procedures.

     
What do people think? Is this an important need? Are there any snags?
Does it do all that is wanted?

John Reid. 
