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,bf5045b7cee3d4b X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!e25g2000prg.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: tagged type as generic parameter Date: Thu, 3 Jan 2008 08:22:24 -0800 (PST) Organization: http://groups.google.com Message-ID: <602e79cf-755f-4600-a2cd-0cabf781136a@e25g2000prg.googlegroups.com> References: 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 1199377344 15843 127.0.0.1 (3 Jan 2008 16:22:24 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 3 Jan 2008 16:22:24 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e25g2000prg.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:19176 Date: 2008-01-03T08:22:24-08:00 List-Id: 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. Or, to put it another way, don't use type extensions just because they're there. To me, #3 stands out as the *correct* solution to the problem, in most cases. Plus, if you do that, Data no longer needs to be a tagged formal type, so that you can use your generic on both tagged and untagged types. -- Adam