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=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca3.giganews.com!border2.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!feeder02.blueworldhosting.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!newsfeed0.kamp.net!newsfeed.kamp.net!newsfeeder.ewetel.de!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!news.online.de!not-for-mail From: Felix Krause Newsgroups: comp.lang.ada Subject: orthogonal inheritance and extension aggregates Date: Fri, 19 Jul 2013 19:46:38 +0200 Organization: 1&1 Internet AG Message-ID: NNTP-Posting-Host: pd95420b6.dip0.t-ipconnect.de Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: online.de 1374255999 7348 217.84.32.182 (19 Jul 2013 17:46:39 GMT) X-Complaints-To: abuse@einsundeins.com NNTP-Posting-Date: Fri, 19 Jul 2013 17:46:39 +0000 (UTC) User-Agent: Unison/2.1.10 X-Original-Bytes: 2711 Xref: number.nntp.dca.giganews.com comp.lang.ada:182591 Date: 2013-07-19T19:46:38+02:00 List-Id: I try to implement some feature via orthogonal inhertance like this: generic type Parent (<>) is abstract tagged private; package Extension is type Extended is abstract new Parent with private; -- operations of the extended type here private type Extended is abstract new Parent with record -- … end record; end Extension; Now for testing, I tried to apply this on a Vector: package Int_Vectors is new Ada.Container.Vectors (Natural, Integer); package Base is new Extension (Int_Vectors.Vector); type Child is new Base.Extended with null record; At the declaration of Child, GNAT tells me "type must be declared abstract or "To_Vector" overridden". Can someone explain why this happens? As I understand it, To_Vector should be automatically defined for the derived type. Is this because the intermediate type Extended is declared abstract? Or because To_Vector dispatches in the return type? Anyway, I tried to declare the function for the type Child like this: function To_Vector (Length : Ada.Containers.Count_Type) return Child is begin return Child'(Base.Extended'(Int_Vectors.To_Vector (Length) with others => <>) with null record); end To_Vector; Firstly, this looks rather awkward. Secondly, it doesn't compile: "expected private type Extended […] found a composite type". I guess this does not work because the type Extended is hidden in the private part of Extension. Is it possible to define To_Vector in this context to do exactly what the base function does? -- Felix Krause http://flyx.org/