comp.lang.ada
 help / color / mirror / Atom feed
* Re: Scope of variables in package ??
       [not found] <31D1A979.103B@vzcorp.com>
  1996-06-27  0:00 ` Scope of variables in package ?? Tucker Taft
@ 1996-06-27  0:00 ` Mark A Biggar
  1996-06-28  0:00 ` John Herro
  2 siblings, 0 replies; 3+ messages in thread
From: Mark A Biggar @ 1996-06-27  0:00 UTC (permalink / raw)


In article <31D1A979.103B@vzcorp.com> "Sandeep V. Kharkar" <skharkar@vzcorp.com> writes:
>If a function/procedure is defined as SEPARATE,i.e.,
>implementation outside the PACKAGE BODY, can it still see
>variables defined inside the PACKAGE BODY but
>not in the PACKAGE SPECIFICATION  ??

No it still sees both.  A separate unit is compiled just as if it were
textually embedded in the package body at the place of the separate
declaration and thus can see everything in the body before that point
and the whole of the spec.

--
Mark Biggar
mab@wdl.lmco.com






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

* Re: Scope of variables in package ??
       [not found] <31D1A979.103B@vzcorp.com>
@ 1996-06-27  0:00 ` Tucker Taft
  1996-06-27  0:00 ` Mark A Biggar
  1996-06-28  0:00 ` John Herro
  2 siblings, 0 replies; 3+ messages in thread
From: Tucker Taft @ 1996-06-27  0:00 UTC (permalink / raw)


Sandeep V. Kharkar (skharkar@vzcorp.com) wrote:
: If a function/procedure is defined as SEPARATE,i.e.,
: implementation outside the PACKAGE BODY, can it still see
: variables defined inside the PACKAGE BODY but
: not in the PACKAGE SPECIFICATION  ??

Yes.  The "up-level" visibility in a "subunit" (a nested unit whose
body is separately compiled) is based on the location of the
subunit's "stub", the place where the "is separate;" appears
in the parent's body.

See RM95 10.1.3(1,17) and 10.1.4(2).

: ~Sandeep

: skharkar@vzcorp.com
: http://www.cs.usu.edu/students/SandeepKharkar/index.html

-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Cambridge, MA  USA




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

* Re: Scope of variables in package ??
       [not found] <31D1A979.103B@vzcorp.com>
  1996-06-27  0:00 ` Scope of variables in package ?? Tucker Taft
  1996-06-27  0:00 ` Mark A Biggar
@ 1996-06-28  0:00 ` John Herro
  2 siblings, 0 replies; 3+ messages in thread
From: John Herro @ 1996-06-28  0:00 UTC (permalink / raw)


"Sandeep V. Kharkar" <skharkar@vzcorp.com> writes:
> If a function/procedure is defined as SEPARATE,i.e.,
> implementation outside the PACKAGE BODY, can it still see
> variables defined inside the PACKAGE BODY but
> not in the PACKAGE SPECIFICATION  ??
     If I understand your question correctly, it can see variables defined
in the package body (above the function/procedure) AND variables defined
in the package specification.  For example,
package P is
   I : Integer;
   procedure Test;
end P;
package body P is
   F : Float;
   procedure Test is separate;
end P;
separate (P)
procedure Test is
   ... -- Test can see both I and F.
end Test;
     There's much, much more to the subject.  For example programs outside
package P that "with" the package can see I but not F.  This feature of
Ada, called information hiding, can help contain the effects of certain
changes to your program, so that they don't impact other parts of the
program.  Private package parts, which I haven't discussed here, improve
information hiding even further.  For more information, download my Ada
Tutor program, available at the Web and FTP sites below my signature.  I
hope this helps.
- John Herro
Software Innovations Technology
http://members.aol.com/AdaTutor
ftp://members.aol.com/AdaTutor





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

end of thread, other threads:[~1996-06-28  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <31D1A979.103B@vzcorp.com>
1996-06-27  0:00 ` Scope of variables in package ?? Tucker Taft
1996-06-27  0:00 ` Mark A Biggar
1996-06-28  0:00 ` John Herro

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