0

Are there any advantages to using a function in place of an external subroutine, such as speed, efficiency, etc.?

Trying to decide how to implement a standard methodology for validating inputs. The routine will be called numerous times, so efficiency is a key consideration.

1 Answers1

0

It may be different between Unidata/Universe, but I think under the covers functions are implemented very similarly to subroutines, so there's probably very little performance difference.

In practice, since CALL has been around forever, most codebases tend not to use DEFFUN, I've only used it a few times.

If you don't ever expect to move to another platform, and if it makes your code cleaner/easier to maintain, then I'd say go for it. But if it doesn't make a huge difference in maintainability, and stability/portability is more important than code "eloquence", then sticking with a plain subroutine is the way to go.

Ian McGowan
  • 3,461
  • 3
  • 18
  • 23