comp.lang.ada
 help / color / mirror / Atom feed
* Help! type extensions - Gnat for Win95
@ 1996-04-14  0:00 Lance 
  1996-04-14  0:00 ` Robert A Duff
  0 siblings, 1 reply; 2+ messages in thread
From: Lance  @ 1996-04-14  0:00 UTC (permalink / raw)


I am trying to make a hierarchy of data structures as a hierarchy of
types.   Consider the following code:

---------------------------------------------------------------------------
package Containers is
  type Container is abstract tagged private;
private
  type Container is abstract tagged null record;
end Containers;

package Containers.Stacks is
  type Stack is new Container with private;
  procedure Put (S: Stack) is abstract;
private
  type Stack is new Container with null record;
end Containers.Stacks;

package Containers.Stacks.Bounded_Stacks is
  type Bounded_Stack is limited private;
private
  type Bounded_STack is new *Stack with record
      ---------
      ---------
  end record;
end Containers.Stacks.Bounded_Stacks;
------------------------------------------------------------------------------------

All of the above code compiles fine.  However, I try to use the
package in test program the compiler tells me  "type extension at
deeper accessibility level than parent." at the line in
Containers.Stacks.Bounded_STacks that defines the type. (marked with *
above)
  

Thanks in advance for any help that you may be able to provide.

Lance
lance@lainet.com




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

* Re: Help! type extensions - Gnat for Win95
  1996-04-14  0:00 Help! type extensions - Gnat for Win95 Lance 
@ 1996-04-14  0:00 ` Robert A Duff
  0 siblings, 0 replies; 2+ messages in thread
From: Robert A Duff @ 1996-04-14  0:00 UTC (permalink / raw)


In article <317169a3.48223533@news.lainet.com>,
Lance  <lance@lainet.com> wrote:
>All of the above code compiles fine.

It shouldn't.  You need to make Stack abstract, since it has an abstract
primitive operation.

>...  However, I try to use the
>package in test program the compiler tells me  "type extension at
>deeper accessibility level than parent." at the line in
>Containers.Stacks.Bounded_STacks that defines the type. (marked with *
>above)

Don't extend these types in procedures or functions.  If the thing is
generic, don't instantiate it in a procedure or function.  Instantiate
it at library level (i.e. as a library unit, or nested within a package,
but not within a procedure).

- Bob




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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-04-14  0:00 Help! type extensions - Gnat for Win95 Lance 
1996-04-14  0:00 ` Robert A Duff

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