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, T_FILL_THIS_FORM_SHORT autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.36.179.70 with SMTP id z6mr358963iti.36.1512267288920; Sat, 02 Dec 2017 18:14:48 -0800 (PST) X-Received: by 10.157.69.72 with SMTP id p8mr456771oti.4.1512267288831; Sat, 02 Dec 2017 18:14:48 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.kjsl.com!usenet.stanford.edu!193no72501itr.0!news-out.google.com!s63ni1412itb.0!nntp.google.com!193no72498itr.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 2 Dec 2017 18:14:48 -0800 (PST) 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 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Full view of a private partial view cannot be a subtype From: Jere Injection-Date: Sun, 03 Dec 2017 02:14:48 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:49323 Date: 2017-12-02T18:14:48-08:00 List-Id: Say I have some type: package Base is type Instance is tagged limited private; procedure Operation(Object : in out Instance); private type Instance is tagged limited null record; procedure Operation(Object : in out Instance) is null; end Base; It might have 20 or so operations, but this is a simplified example. 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; (NOTE: is there a better way to do this?) This is all well and good, but sometimes while I as an implementer want this kind of relationship, I don't necessarily want to expose that relationship outside the private section of a package. Here I run into a problem as I cannot (as far as I can tell) do: package New_Type2 is type Instance is tagged limited private; procedure Operation(Object : in out Instance); private subtype Instance is Base.Instance; procedure Operation(Object : in out Instance renames Base.Operation; end New_Type2; as it fails with an error ("Instance" not type conformant with declaration) on the subtype line. Instead I have to do (again, unless there is a better way): package New_Type2 is type Instance is tagged limited private; procedure Operation(Object : in out Instance); private type Instance is new Base.Instance with null record; end New_Type2; package body New_Type2 is procedure Operation(Object : in out Instance) is begin Base.Instance(Object).Operation; end Operation; end New_Type2; This might be ok, but it's a lot of noise added (I now need a body for all of my operations and need to type convert parameters and any return values). I'm also not sure the semantics between the method I wanted and the method I had to use are the same (in all situations). I.E. I don't know if procedure Operation(Object : in out Instance renames Base.Operation; has the same semantics as procedure Operation(Object : in out Instance) is begin Base.Instance(Object).Operation; end Operation; My instinct says they do not. That may be ok, but I am just unsure. 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?