comp.lang.ada
 help / color / mirror / Atom feed
* "Common" data
@ 1994-10-12 17:37 Bob Wells #402
  1994-10-12 14:38 ` Robert I. Eachus
  1994-10-13 13:45 ` Norman H. Cohen
  0 siblings, 2 replies; 6+ messages in thread
From: Bob Wells #402 @ 1994-10-12 17:37 UTC (permalink / raw)


G'day,
Where abouts in the LRM does it say that I will only have one copy
of the variable T in the following code? This is naturally what you
would expect, that A.New_T_Value and B.New_T_Value would be working
on the same T, but is this defined in the LRM?

This is a trivialization of some comms code delivered to us, and we
wanted to see if the behaviour was defined by the LRM.

---------------------------------------
package Common is

  procedure Update_T;

end Common;

package body Common is

  T : Integer;

  procedure Update_T is

  begin

    ..
    code which updates the variable T;
    ..

  end Update_T;

end Common;

---------------------------------------

package A is

   procedure New_T_Value;

end A;

with Common;
package body A is

  procedure New_T_Value is

  begin

    Common.Update_T;

  end New_T_Value;

end A;

---------------------------------------

package B is

   procedure New_T_Value;

end B;

with Common;
package body B is

  procedure New_T_Value is

  begin

    Common.Update_T;

  end New_T_Value;

end B;

---------------------------------------

with A;
with B;
procedure Main is

begin

  A.New_T_Value;

  B.New_T_Value;

end Main;

Any confirmation of this would be greatly appreciated.

Thanks!

@                   --------
@          ////  - ( G'day! )
@         (o o)     --------
@ ----oOO--(_)--OOo--------------------------------------------------------
  Bob Wells                             "For every action there is an equal
                                         and opposite government program."
@ INTERNET: wel@eurocontrol.de                 CompuServe:      100272,3004
@ The Ada WWW Server is http://lglwww.epfl.ch/Ada/                 Team Ada
@ For exciting Ada info enter 'finger wel@s4ecawel.eurocontrol.de'



^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: "Common" data
@ 1994-10-13 13:22 Keith Arthurs
  0 siblings, 0 replies; 6+ messages in thread
From: Keith Arthurs @ 1994-10-13 13:22 UTC (permalink / raw)


In article <9410121737.AA28756@eurocontrol.de>,
 on Wed, 12 Oct 1994 18:37:08 +0100,
 Bob Wells
>Subject: "Common" data
>From: Bob Wells #402 <wel@EUROCONTROL.DE>
>Newsgroups: comp.lang.ada
>Message-ID: <9410121737.AA28756@eurocontrol.de>
>Date: Wed, 12 Oct 1994 18:37:08 +0100
>
>G'day,
>Where abouts in the LRM does it say that I will only have one copy
>of the variable T in the following code? This is naturally what you
>would expect, that A.New_T_Value and B.New_T_Value would be working
>on the same T, but is this defined in the LRM?
>
>This is a trivialization of some comms code delivered to us, and we
>wanted to see if the behaviour was defined by the LRM.
>
[code Snipped]
>>Thanks!>

  In the LRM section 7.3:3 it states that a variable declared in the body of
a package is only visible within this body...  This defines the "visibility" of
the variable as within the package body.  The paragraph goes on to say that
the the value of such a variable remains unchanged between calls issued from
outside the package to subprograms declared in the visible part.  This defines
the "scope" as the life of the program.  So when you call a routine in package
common, no matter where it is being called from, it is working on the same
storage.


Keith Arthurs
McDonnell Douglas Corporation
Disclaimer: I do not intend for the above commentary to reflect any opinions
            of McDonnell Douglas.  If they do its by pure coincidence.




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1994-10-13 13:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1994-10-12 17:37 "Common" data Bob Wells #402
1994-10-12 14:38 ` Robert I. Eachus
1994-10-13  3:21   ` Tucker Taft
1994-10-13 11:47     ` Robert I. Eachus
1994-10-13 13:45 ` Norman H. Cohen
  -- strict thread matches above, loose matches on Subject: below --
1994-10-13 13:22 Keith Arthurs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox