From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a3c2ec05bff4ab48 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!a32g2000prf.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Ada: Inheritance of generics Date: Mon, 2 Jun 2008 08:13:09 -0700 (PDT) Organization: http://groups.google.com Message-ID: <1755c5d8-8c27-4219-8670-80086f098ba5@a32g2000prf.googlegroups.com> References: <1d2swajw7rsue$.ftt2098a7wvt$.dlg@40tude.net> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1212419589 16241 127.0.0.1 (2 Jun 2008 15:13:09 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 2 Jun 2008 15:13:09 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a32g2000prf.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:524 Date: 2008-06-02T08:13:09-07:00 List-Id: On Jun 2, 7:17 am, Dennis Hoppe wrote: > Dmitry A. Kazakov wrote: > > On Mon, 02 Jun 2008 15:39:05 +0200, Dennis Hoppe wrote: > > >> -- child unit > >> generic > >> -- omitted > >> package Generic_Child is > >> type Object is new Generic_Parent.Object with private; > > > This is illegal. Generic_Parent is a generic unit, you cannot refer to > > anything within it without either instantiation of, or else from a generic > > child unit of. Generic_Child is not a child package of Generic_Parent. > > Hmm...this line is really a left over from simple inheritance without > generic unit, but the Ada compiler does not complain about it. > > > P.S. Except for trivial cases, it is always better to post complete code > > samples. > > I thought, this example was exhaustive: parent, child, instantiation. "Complete code sample" means something that you can compile. In this case, it's hard to tell what you're trying to do. If your units are all top-level library units, there's a lot of WITH's missing; plus 2**16 is not a type, so you can't instantiate Generic_Package with it, and there's no completion for the private type extension Object, you've tried to instantiate a type instead of a generic package. Sometimes it's good enough to leave stuff out, but in this case I can't tell what you're trying to do, and I suspect I'm not alone. There's so many things wrong with this code that I'm just going to take a guess at what you're trying to do and hope it's close to what you're looking for. If not, you'll need to explain more about what you're trying to accomplish. The following Ada source does compile. generic type Modular_Type is mod <>; package Generic_Parent is type Object is abstract tagged limited null record; function Example return Integer; end Generic_Parent; -- child unit generic -- omitted package Generic_Parent.Generic_Child is type Object is new Generic_Parent.Object with private; function Example return Integer; private type Object is new Generic_Parent.Object with null record; -- or whatever you want in the type extension end Generic_Parent.Generic_Child; package Mod_Package is type Unsigned_16 is mod 2**16; end Mod_Package; with Generic_Parent; with Mod_Package; package Parent is new Generic_Parent (Mod_Package.Unsigned_16); with Parent; with Generic_Parent.Generic_Child; package Child is new Parent.Generic_Child; with Child; package Pak1 is A : Integer := Child.Example; end Pak1; -- HTH, Adam