Re: MODULEand USE versus Argument Passing



"Herman D. Knoble" wrote:
>
> Given a Subprogram that gets called millions of times,
> we know that there is (CPU) overhead for subprogram linkage.
>
> My question is, independent of compilers, which is more efficient
> in practice:
>
> passing a list of (say 3 to 10) arguments to a subprogram's
> corresponding parameters,
> OR using a Module and companion USE statement,
> OR use named COMMON?

The difference in access times between placing global data in a
MODULE vs a COMMON block should be a wash. Of course there are many
other reasons to use MODULEs over COMMON blocks.

Unless something is seriously wrong, like unanticipated array
copying, the difference in time between passing N args and N+1 args
is usually virtually immeasurable. It is the fact that you are doing
the call in the first place that may be expensive. And as other
posters have mentioned, inlining and other IPA can often eliminate
this overhead.

As to the desirability of passing data using MODULE data vs dummy
args, the answer is "it depends". Generally, less global data makes
for better modularity/reusability of code. But there are perfectly
good reasons for using global data too. And procedures with 'eleventy-
five' arguments in the list are pretty clunky too.

Walt
-...-
Walt Spector
(w6ws att earthlink dott net)
.