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.50.22 with SMTP id j22mr773439ita.10.1513645307531; Mon, 18 Dec 2017 17:01:47 -0800 (PST) X-Received: by 10.157.51.145 with SMTP id u17mr58020otc.7.1513645307346; Mon, 18 Dec 2017 17:01:47 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.unit0.net!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!g80no109303itg.0!news-out.google.com!b73ni307ita.0!nntp.google.com!i6no110088itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 18 Dec 2017 17:01:46 -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: <5b32a99e-04e5-4adb-8b42-88e485570641@googlegroups.com> <83982113-349e-4443-b457-e63d749ad42a@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: Tue, 19 Dec 2017 01:01:47 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:49529 Date: 2017-12-18T17:01:46-08:00 List-Id: On Sunday, December 17, 2017 at 10:39:17 AM UTC-5, Dmitry A. Kazakov wrote: > On 2017-12-17 16:26, Jere wrote: > > > my assertion is that: > > > > subtype Thing is Core_Pkg.Thing; > > > > procedure Do_Something(The_Thing : in out Thing) > > renames Core_Pkg.Do_Something; > > > > > > is easier to both maintain and read than: > > > > type Thing is new Core_Pkg.Thing with null record; > > > > procedure Do_Something(The_Thing : in out Thing); > > But these are two semantically different concepts. Ada's subtype > declares an equivalent type [it inherits everything from and exports > everything to the base]. Ada's new tagged type declares a new instance > of a class. It only inherits. > > I don't understand how can you exchange one for another. > > -- > Regards, > Dmitry A. Kazakov > http://www.dmitry-kazakov.de I don't want to exchange one for the other. I have a package that I want to provide default arguments to privately but maintain the same exact type/operation specification. Subtyping seems more correct than inheritance in this case. I'm not trying to define a new type or an extension of a type. I just want provide a simpler interface to a much more complex generic while hiding part of that so the user doesn't accidentally do something they shouldn't. Something like: generic type Item_Type(<>); type Item_Access is access Item_type; with procedure Deallocation(Ref : in out Item_Access); package Sledgehammer is private end Sledgehammer; This would be used in maybe 5% or less of the code base and only when absolutely necessary. I want to convert it to: generic type Item_Type(<>) is limited private; package Nicer_Package is type Item_Access is access Item_Type; private procedure Deallocate is new Ada.Unchecked_Deallocation (Item_Type,Item_Access); package Implementation is new Sledgehammer (Item_Type => Item_Type, Item_Access => Item_Access, Deallocation => Deallocate); end Nicer_Package; Since all I am doing is automating the access type and the deallocation operation, I don't think a new type is really the right design. Additionally, I don't want to expose the deallocation operation as it should never be called directly. Based on earlier conversion from Jeff, it looks like composition is my best bet since I cannot do it via subtyping and renames. I was just hoping there was a way I could do it without adding so much extra stuff to read and maintain. I don't like decreasing readability like that. If I am willing to expose the deallocation operation, then I can just use subtype and renames (which make more sense to me in this case) but that's the tradeoff.