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 2002:a05:620a:10a9:: with SMTP id h9mr10450687qkk.408.1590070815759; Thu, 21 May 2020 07:20:15 -0700 (PDT) X-Received: by 2002:a05:6830:168c:: with SMTP id k12mr7117961otr.342.1590070815463; Thu, 21 May 2020 07:20:15 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 21 May 2020 07:20:15 -0700 (PDT) In-Reply-To: <7ec397ae-f1be-4791-9e83-278f0ee2aded@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=199.212.255.56; posting-account=ENgozAkAAACH-stq5yXctoDQeZQP2E6J NNTP-Posting-Host: 199.212.255.56 References: <3e90280f-ea64-4f85-a1fa-5d2fc75e0ddf@googlegroups.com> <7ec397ae-f1be-4791-9e83-278f0ee2aded@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <7f6e7b7e-f5c3-4624-b59e-020d215152e1@googlegroups.com> Subject: Re: Q: How to inherit methods from parent tagged object? From: Warren Injection-Date: Thu, 21 May 2020 14:20:15 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:58755 Date: 2020-05-21T07:20:15-07:00 List-Id: On Thursday, 21 May 2020 09:50:24 UTC-4, Jere wrote: > On Thursday, May 21, 2020 at 9:23:52 AM UTC-4, Warren wrote: > > I've become rusty and am refreshing myself with Ada again using a pet project.. > > > > I have a tagged class that I want to inherit all but one of the methods for: > > > > type Flash is new Emulator.Memory.Flash with private; > > > > procedure Initialize(Obj: in out Flash); > > -- function Fetch(Obj: in out Flash; Address: Address_Type) return Word_Type; > > -- function First_Address(Obj: in Flash) return Address_Type; > > -- function Last_Address(Obj: in Flash) return Address_Type; > > > > The only thing I want to override in the new object is the Initialize procedure for the new object. There must be a way to specify that but I can't seem to goggle it on the interwebs. Every example I can find completely redefines all of the methods. > > > > I'd like to avoid re-specifying the bodies of Fetch, First_Address and Last_Address for the new object, if that is permitted. If memory serves, there is a way... but the worms have invaded my brain. > > I feel like you are either leaving out some other info about > Emulator.Memory.Flash or I am just completely misunderstanding. > If you only want to override Initialize, then just do that: > > type Flash is new Emulator.Memory.Flash with private; > overriding procedure Initialize(Obj: in out Flash); > > The "overriding" keyword is optional but good practice. Doing this > will override Initialize but not the other operations. If this > doesn't work you need to tell us more about any errors you are > encountering. Note that this is true for almost all languages > that support inheritance, you just override the operations you want > to and the rest will just use the baseclass version. When I just try to override Initialize, I get the error: emulator-memory-attiny13.ads:46:09: missing full declaration for private extension Arrrg, I found the problem.. and am embarrassed to say, I was missing the: type Flash is new Emulator.Memory.Flash with null record; in the private section. DOH! Thanks for your time.