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.1 required=5.0 tests=BAYES_00,REPLYTO_WITHOUT_TO_CC, UNCLOSED_BRACKET autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,bf5045b7cee3d4b X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.germany.com!newsfeed-0.progon.net!progon.net!newsfeed.ision.net!newsfeed2.easynews.net!ision!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: tagged type as generic parameter Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <602e79cf-755f-4600-a2cd-0cabf781136a@e25g2000prg.googlegroups.com> Date: Thu, 3 Jan 2008 17:58:01 +0100 Message-ID: <17k6uddmxknzi$.1q1crpca0ygrf.dlg@40tude.net> NNTP-Posting-Date: 03 Jan 2008 17:58:04 CET NNTP-Posting-Host: 37dfdbd7.newsspool1.arcor-online.net X-Trace: DXC=WO[GS660nh785[]]\]T081ic==]BZ:af>4Fo<]lROoR14nDHegD_]R5e:L_ZQKMN@?DNcfSJ;bb[5IRnRBaCdhfl:aCbVd972O6ZScnY_[4 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:19177 Date: 2008-01-03T17:58:04+01:00 List-Id: On Thu, 3 Jan 2008 08:22:24 -0800 (PST), Adam Beneschan wrote: > On Jan 3, 7:51 am, "Dmitry A. Kazakov" > wrote: > >> 3. Aggregation instead of inheritance: >> >> type Item is record >> Next : Item_Ptr; >> Value : Data; >> end record; >> >> No inheritance, no problem. > > Actually, I think the OP really needs a darn good reason why he would > want Item to be inherited from his generic formal type, rather than > simply a record containing a value and a link as in your above > suggestion. Conceptually, at least to me, a type extension is > supposed to define a type that is a "kind of" the parent type. In > this case, Item, as the OP originally defined it, doesn't really fit > the concept. It's not really a "kind of" Data with additional > properties. I'm sorry that my "pedagogical" understanding of object- > oriented programming isn't solid enough that I understand what terms > to use, but hopefully I'm getting some sort of notion across. A reason might be to be able to use list items and their content interchangeably, another could be to handle unconstrained data. However, these are certainly not the case for the OP's code. Because Item is private there and Data is constrained. And even if Item were visible, then the right way would likely be #2, because "anything tagged" as in OP's code does not tell much about the inherited semantics of list elements. IMO, your understanding of OOP is quite right. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de