comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: Controlled type question
Date: 1999/02/15
Date: 1999-02-15T00:00:00+00:00	[thread overview]
Message-ID: <m3zp6g1cs7.fsf@mheaney.ni.net> (raw)
In-Reply-To: 36c743da.0@silver.truman.edu


v025@truman.edu (Chad R. Meiners) writes:

> I am constructing a generic hash table ADT with the gnat 3.11p
> compiler on win NT 4.0 SP3 and I have run into a compilier error when
> I try to use the generic package.

[snip]
 
> I get the following errors
> instantiation error at protected_hash_tables.ads :99
> instantiation error at protected_hash_tables.ads :20
> Controlled type must be declared at the library level
> 
> The lines in protected_hash_tables are
> 
> 99 :  Type cObject is new Limited_Controlled with record
...
> 20 :  Type cObject is new Limited_Controller with private;--hash table object
> 
> 
> the package compilied correctly so I think I might of run up against a
> rule in the ARM.  If anyone could explain what I did wrong please do
> so.  I will post more code if you need it.


Yes, you hit upon a rule, the one that says 

  Controlled type must be declared at the library level

You have this:

  package GP is
    ...
  private
    type T is new <controlled type> ...;
  end GP;


That's fine, but the illegal thing is doing this:

package Q is
...
   package P is new GP (...);

end Q;

The problem is that inside the scope of package Q, you're not at library
level, and so the instantiation of GP is illegal.

You can try fixing it like this:

package Q is
...
end Q;

private package Q.P is new GP (...);


(I think that's it.  Let me know if I interpreted things incorrectly.)




  reply	other threads:[~1999-02-15  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-14  0:00 Controlled type question Chad R. Meiners
1999-02-15  0:00 ` Matthew Heaney [this message]
1999-02-15  0:00   ` Chad R. Meiners
replies disabled

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