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 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Full view of a private partial view cannot be a subtype Date: Sun, 3 Dec 2017 13:01:47 +0100 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 3 Dec 2017 12:01:48 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="981a73b697aa3d294792fec12e070ae2"; logging-data="24828"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19cDx5oiFFmyLmAwEoQOqJCwDT5S+k9NVg=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 In-Reply-To: Content-Language: en-US Cancel-Lock: sha1:NdPoFxW7n60xypJmhwP0rU3Lwws= Xref: reader02.eternal-september.org comp.lang.ada:49327 Date: 2017-12-03T13:01:47+01:00 List-Id: On 12/03/2017 03:14 AM, Jere wrote: > > 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; You can make the renaming visible as well. There doesn't seem to be any reason to hide the fact that Operation is a renaming of Base.Operation. > 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). No, with a direct renaming, a call to the renaming is the same as a call to the original procedure. With a wrapper around the call to the original procedure, you have 2 calls. If you inline the wrapper then they should be equivalent. > 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? You cannot use a subtype to complete a private type. But you're not forced to use a derived type and convert all over the place. Another option is private type T is [tagged] [limited] record V : Base.T; end record; and then refer to Object.V with no conversions. If your private type doesn't need to be tagged, you can also do private type T is array (1 .. 1) of Base.T; and then refer to Object (1), again with no conversions. Given that the bounds are static and you're always going to use a static index, I'd expect the indexing to be optimized away. -- Jeff Carter "So if I understand 'The Matrix Reloaded' correctly, the Matrix is basically a Microsoft operating system--it runs for a while and then crashes and reboots. By design, no less. Neo is just a memory leak that's too hard to fix, so they left him in ... The users don't complain because they're packed in slush and kept sedated." Marin D. Condic 65