comp.lang.ada
 help / color / mirror / Atom feed
* Q re static deferred constants
@ 1997-07-16  0:00 Tom Moran
  1997-07-17  0:00 ` Robert A Duff
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Tom Moran @ 1997-07-16  0:00 UTC (permalink / raw)



Given:
package p is 
  type T is new Integer;
  x : constant T;
private
  x : constant T := 1;

Is p.x static?  ie, can another package use p.x for a 'when' in a case
statement?




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

* Re: Q re static deferred constants
  1997-07-16  0:00 Q re static deferred constants Tom Moran
@ 1997-07-17  0:00 ` Robert A Duff
  1997-07-17  0:00 ` Tucker Taft
  1997-07-19  0:00 ` Tom Moran
  2 siblings, 0 replies; 5+ messages in thread
From: Robert A Duff @ 1997-07-17  0:00 UTC (permalink / raw)



In article <33CDB52B.25FE@bix.com>, Tom Moran  <tmoran@bix.com> wrote:
>Given:
>package p is 
>  type T is new Integer;
>  x : constant T;
>private
>  x : constant T := 1;
>
>Is p.x static?  ie, can another package use p.x for a 'when' in a case
>statement?

No.

If X were static, then this would constitute a violation of privacy.  It
should not be possible to make a modification to a private part that
causes clients to become illegal.  If X were static, then such
modifications would be possible.

On the other hand, inside the package body, or anywhere else where that
private part is visible (child packages) X is of course static.

A good compiler will take advantage of the compile-time-known value 1,
despite the fact that X is not static (when viewed from outside).  But
that's a code-generation issue, not a legality issue.

- Bob




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

* Re: Q re static deferred constants
  1997-07-16  0:00 Q re static deferred constants Tom Moran
  1997-07-17  0:00 ` Robert A Duff
@ 1997-07-17  0:00 ` Tucker Taft
  1997-07-19  0:00 ` Tom Moran
  2 siblings, 0 replies; 5+ messages in thread
From: Tucker Taft @ 1997-07-17  0:00 UTC (permalink / raw)



Tom Moran (tmoran@bix.com) wrote:

: Given:
: package p is 
:   type T is new Integer;
:   x : constant T;
: private
:   x : constant T := 1;

: Is p.x static?  ie, can another package use p.x for a 'when' in a case
: statement?

If the full definition of X is not visible, then X is not static.
So inside the package body for P, and those of its children, X is static, 
but outside these places is not.

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




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

* Re: Q re static deferred constants
  1997-07-16  0:00 Q re static deferred constants Tom Moran
  1997-07-17  0:00 ` Robert A Duff
  1997-07-17  0:00 ` Tucker Taft
@ 1997-07-19  0:00 ` Tom Moran
  1997-07-20  0:00   ` Tucker Taft
  2 siblings, 1 reply; 5+ messages in thread
From: Tom Moran @ 1997-07-19  0:00 UTC (permalink / raw)



Tucker Taft said:
> :   type T is new Integer;
> :   x : constant T;
> : private
> :   x : constant T := 1;
>  
> : Is p.x static?  ie, can another package use p.x for a 'when' in a case
> : statement?
>  
> If the full definition of X is not visible, then X is not static.
> So inside the package body for P, and those of its children, X is static,
> but outside these places is not.
  So given
x : constant T;
y : constant T := 2;
private
x : constant T := 1;
  then y is everywhere static but x is static only in P or its children?




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

* Re: Q re static deferred constants
  1997-07-19  0:00 ` Tom Moran
@ 1997-07-20  0:00   ` Tucker Taft
  0 siblings, 0 replies; 5+ messages in thread
From: Tucker Taft @ 1997-07-20  0:00 UTC (permalink / raw)



Tom Moran (tmoran@bix.com) wrote:
: ...
:   So given
: x : constant T;
: y : constant T := 2;
: private
: x : constant T := 1;
:   then y is everywhere static but x is static only in P or its children?

Yes.

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




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

end of thread, other threads:[~1997-07-20  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-07-16  0:00 Q re static deferred constants Tom Moran
1997-07-17  0:00 ` Robert A Duff
1997-07-17  0:00 ` Tucker Taft
1997-07-19  0:00 ` Tom Moran
1997-07-20  0:00   ` Tucker Taft

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