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 X-Received: by 10.36.189.131 with SMTP id x125mr277959ite.37.1513629929544; Mon, 18 Dec 2017 12:45:29 -0800 (PST) X-Received: by 10.157.5.211 with SMTP id 77mr38597otd.0.1513629929277; Mon, 18 Dec 2017 12:45:29 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.kjsl.com!usenet.stanford.edu!g80no31757itg.0!news-out.google.com!b73ni89ita.0!nntp.google.com!i6no32393itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 18 Dec 2017 12:45:28 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=76.218.37.33; posting-account=W2gdXQoAAADxIuhBWhPFjUps3wUp4RhQ NNTP-Posting-Host: 76.218.37.33 References: 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: Stephen Leake Injection-Date: Mon, 18 Dec 2017 20:45:29 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:49519 Date: 2017-12-18T12:45:28-08:00 List-Id: On Saturday, December 2, 2017 at 8:14:50 PM UTC-6, Jere wrote: > There are times where in another package I want to > subtype Base.Instance and do renames of the operations in order > to bring them all into scope (or whatever the correct term is): > > package New_Type1 is > subtype Instance is Base.Instance; > procedure Operation(Object : in out Instance); > > private > > procedure Operation(Object : in out Instance) renames Base.Operation; > end New_Type1; Why subtype? why not a derived type? why do you need a new name with the same operations? > (NOTE: is there a better way to do this?) Yes, use a derived type: type Instance is new Base.Instance; Since Base.Instance is not abstract, you don't need to do anything else; all the operations are inherited. Optionally, you can override some operations to change what they do. > So I guess my question is two part: > > 1. Is there a way to make the full view of a private type > a subtype when the partial view is not a subtype? Or am > I forced to derive a new type? > > 2. If it isn't possible, are there any language reasons for > why that must be so? Would making a full view of a type > actually a subtype under the hood break something? subtypes just declare a new name with new constraints; derived types declare a new type. So you'd be lying to the clients of the package; that always causes problems. -- Stephe