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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.36.105.1 with SMTP id e1mr2271659itc.6.1512339783739; Sun, 03 Dec 2017 14:23:03 -0800 (PST) X-Received: by 10.157.32.78 with SMTP id n72mr567097ota.12.1512339783627; Sun, 03 Dec 2017 14:23:03 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.kjsl.com!usenet.stanford.edu!193no631180itr.0!news-out.google.com!s63ni2612itb.0!nntp.google.com!193no631176itr.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 3 Dec 2017 14:23:03 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.71.208.22; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 173.71.208.22 References: <889a3aed-4e6b-49c8-8c1c-6f1478e8e077@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Full view of a private partial view cannot be a subtype From: Jere Injection-Date: Sun, 03 Dec 2017 22:23:03 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:49340 Date: 2017-12-03T14:23:03-08:00 List-Id: On Sunday, December 3, 2017 at 9:34:51 AM UTC-5, Jeffrey R. Carter wrote: > On 12/03/2017 02:33 PM, Jere wrote: > > Thanks! I didn't even think about nesting it like that. That'll work. > > Many people seem to think that as much as possible should be done through type > extension. They act as though the only tool they have is the hammer of type > extension, and so view every problem as a nail. In my experience type extension > is usually best avoided whenever possible. > Well, I think either form is a bit too polar. I've always been taught that you use the tool that makes the most sense given the context. If a type has an "is a" relationship, you favor extension. But if it has a "has a" relationship, you favor composition. If the situation is unique enough, then you do something outside the norm. In this case I wasn't using extension because I thought it was the best method. I was using it because Ada doesn't provide me a good way to rename a type as part of the full view. Normally I would use subtype, but I can't do that with a private declaration (I don't want the client to have access to the "subtypedness", but I want to leverage it under the hood). Extension was my first stab at it because of the natural flow of type declarations in Ada. I did run into a snag with using composition. Some of my functions return numeric or access types that are created within the generic that I am trying to use. I'll still have to do conversions for those since I want them to retain their numeric and access properties (so a private nested type won't do).