Kurt W Hirchert writes:
[example code elided]
> 1. Van is incorrect. Because main uses module routines and routines uses
> module shared, everything in shared (i.e., the variable value) has a
> lifetime at least as long as that of the main program and thus would behave
> no differently if the SAVE attribute were removed....
>
> 2. Bill is also incorrect. He is correct that value is PUBLIC in module
> routines, but since main says "only: routine" when it uses module routines,
> value is _not_ accessible in main.
I was going to say something similar (but Kurt words it better). To
elaborate on one point, let me note that the "lifetime" of a module
variable depends only on whether the module is used, not on whether
the particular variable is accessible. That's the distinction being
made here - the two conditions are not necessarily the same in the
presense of such things as ONLY.
Note that this is all essentially identical to COMMON. If you don't
understand how modules act in this regard, then you don't/didn't
understand the same issue in COMMON. And although COMMON doesn't have
anything like ONLY, it does have a distinction between accessing the
COMMON and accessing a variable "in" it. The same COMMON may have
a different set of variable names in different scopes (for a
fairly "common" example, there could be a list of scalars in some
scopes, but a single array in others); doesn't matter in that it still
counts as accessing the COMMON for the purposes of defining
"lifetime".
--
Richard Maine
[log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|