3

I'm pretty new to Java. What would be the "standard" way in Java to simulate the FORTRAN EXTERNAL concept? For example to compute the integral of a function where the function is not predefined?

For the reminder, FORTRAN EXTERNAL is a way to pass a "reference" of a function to another subprogram or function. It looks like: http://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vn9d/index.html

  • http://stackoverflow.com/questions/4685563/how-to-pass-a-function-as-a-parameter-in-java – apnorton Jan 01 '14 at 17:54
  • 7
    You might want to elaborate a bit on what the FORTRAN EXTERNAL concept is, not all of us who use Java know any FORTRAN. – Dennis Meng Jan 01 '14 at 17:55
  • FORTRAN EXTERNAL is a way to pass a "reference" of a function to another subprogram or function. It looks like: [link]http://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vn9d/index.html. An old dinosaur... – mathcounterexamples.net Jan 01 '14 at 18:11
  • @jpmjpmjpm Mind if you put that into the question itself, and not just in the comments? Comments are a lot more temporary (and they can also be hidden, which would mean others stumbling here miss context). – Dennis Meng Jan 01 '14 at 22:58

1 Answers1

1

Design an interface which has one method, called "apply()" or "calculate" or whatever, with the signature of the function you'll want to invoke.

Write your processing class so it gets passed an object which implements that interface, and calls it to invoke the external operation.

Write classes that implement the interface and perform the desired functions.

Then write whatever wrapper is needed to apply the processing class to the function classes.

keshlam
  • 7,931
  • 2
  • 19
  • 33