On Tue, 2 Mar 2004, 4:58pm -0500, [log in to unmask] wrote:
> One thought: since different routines can map out a common
> area in different ways, use of the common by one routine
> could be undone by its use by another, mapping it differently.
> Perhaps that is what was meant.
Yup.
> But then how would SAVE fix this?
It wouldn't. It's *not* using SAVE that can confer advantages.
Let's see if I can get this right. :-)
Example 1:
* MAIN calls subroutine A, then B
* A and B include the same named COMMON, which is not
included in MAIN.
* With SAVE, it is guaranteed that the COMMON variables will retain
their values between A and B. (Including the COMMON block in MAIN
would have the same effect.)
* Without SAVE, there is no such guarantee. For instance, the
COMMON could be allocated on the stack, and the values set
in the COMMON in A could not be relied to be there by the
time B was called.
What *leaving SAVE off* could accomplish is the following.
Example 2:
* MAIN calls subroutine A, then B
* A calls AA and B calls BB
* A, AA, B and BB include a COMMON of the same name, which is not
included in MAIN
* A and AA declare the named COMMON with 10 words of data
* B and BB declare the named COMMON with 10000 words of data
* A and AA can then communicate through this COMMON
* B and BB can then communicate through this COMMON
* While A and AA are communicating, we haven't wasted the
9990 words of stack space that B and BB will need.
In practice, however, COMMON is usually allocated on the heap.
Thus, the semantics of COMMON as static storage, which you
expected, are usually observed in practice, even without SAVE.
That is, you would expect Example 1 to work correctly even
without SAVE. The standard explicitly permits implementations
to allow Example 1 to fail, however, just in order to allow
the sort of economy implied by Example 2.
-P.
--
Peter S. Shenkin Schrodinger, Inc.
VP, Software Development 120 W. 45th St., 32nd Floor
646 366 9555 x111 Tel New York, NY 10036
646 366 9550 FAX USERID: shenkin
http://www.schrodinger.com DOMAIN: schrodinger DOT com
Pre-arranged conf. calls: 702-759-8420 or 888-867-7084; passcode 646-366
|