comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison<dennison@telepath.com>
Subject: Re: Q: generic children of generic packages?
Date: Mon, 11 Jun 2001 18:55:47 GMT
Date: 2001-06-11T18:55:47+00:00	[thread overview]
Message-ID: <Tu8V6.4153$pb1.161057@www.newsranger.com> (raw)
In-Reply-To: vc566e250pw.fsf@grinch.htc.honeywell.com

In article <vc566e250pw.fsf@grinch.htc.honeywell.com>, Steve Vestal says...
>
>Here's what I tried, with the error messages included as comments.  The
>problem seems to occur in the attempt to instantiate the generic child

..as I guessed. (owch! I think I just wrenched my shoulder patting myself on
the back there.)

>generic
>package Generic_Parent is
..
>generic
>package Generic_Parent.Generic_Child is

So far so good...

>package Parent is new Generic_Parent;
>-- parent-child.ads:5:35: "Generic_Child" not declared in "Parent"
>-- Can also try the following, with following results.
>--with Parent.Generic_Child;
>-- main.adb:2:06: file "parent-generic_child.ads" not found
>package Parent.Child is new Parent.Generic_Child;

Three things here. First off, as I said before, you must instantiate from an
instance of the generic, not from a generic. You seem to have picked that one
up. However, you don't need to "with" something you just declared yourself
locally. That's why you are getting an error trying to "with
Parent.Generic_Child".  Lastly, the new "Child" package that you are creating
isn't really a child package once you instantiate it, so you can't give it a
parent in the declaration (Think of it as something akin to a "renames" that
does some actual work).

I haven't compiled this, but you should try:

with Generic_Parent.Generic_Child;  -- implicitly "with"s Generic_Parent

package Parent is new Generic_Parent;
package Child is new Parent.Generic_Child;


If you don't mind downloading and looking through someone else's code, the
example and test directories in OpenToken (
http://www.telepath.com/dennison/Ted/OpenToken/OpenToken.html ) contain quite a
few examples of instantiation of generic children of generic packages. Also, 
any code showing use of the Ada95 Booch Components would contain good examples
(but I don't know where any of those are online).

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



      parent reply	other threads:[~2001-06-11 18:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-11 16:35 Q: generic children of generic packages? Steve Vestal
2001-06-11 17:27 ` Ted Dennison
2001-06-11 18:29   ` Steve Vestal
2001-06-11 18:41     ` Ed Falis
2001-06-11 18:55     ` Ted Dennison [this message]
replies disabled

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