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.107.143.132 with SMTP id r126mr13324471iod.7.1512402266435; Mon, 04 Dec 2017 07:44:26 -0800 (PST) X-Received: by 10.157.14.137 with SMTP id 9mr676778otj.14.1512402266307; Mon, 04 Dec 2017 07:44:26 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.kjsl.com!usenet.stanford.edu!193no1113102itr.0!news-out.google.com!b73ni964ita.0!nntp.google.com!i6no2811031itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 4 Dec 2017 07:44:26 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2003:c7:83d0:5ce1:f437:98fe:9073:e3b9; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf NNTP-Posting-Host: 2003:c7:83d0:5ce1:f437:98fe:9073:e3b9 References: <4db43571-7f86-4e73-8849-c41160927703@googlegroups.com> <6496a10f-c97e-4e42-b295-2478ad464b2f@googlegroups.com> <6106dfe6-c614-4fc1-aace-74bf8d7435e3@googlegroups.com> <24767ee5-cda8-45e4-98d1-7da44757bd40@googlegroups.com> <037e7f02-9149-4648-b7c5-91f67c1c1961@googlegroups.com> <4ea6417a-d352-4af4-bfe5-241910bc9684@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <18484b80-247e-4d01-9aea-2b60899846ac@googlegroups.com> Subject: Re: Extending a third party tagged type while adding finalization From: AdaMagica Injection-Date: Mon, 04 Dec 2017 15:44:26 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:49354 Date: 2017-12-04T07:44:26-08:00 List-Id: Aha, now I see what you are talking about. That's what I meant with cryptic message. You too often just expect mind reading (especially difficult with illegal code snippets). Am Montag, 4. Dezember 2017 14:55:23 UTC+1 schrieb Dmitry A. Kazakov: > On 04/12/2017 14:19, AdaMagica wrote: > > > There is no Initialize defined for derived S. This is defined then implicitly as: > > > > procedure Initialize (X: in out S) is > > begin > > Initialize (T (X)); > > end Initialize; > > > > This is the calling sequence: > > Init S > > Init T > > Foo S > > Which is a wrong sequence per Ada design. Actually it is just > > Initialize of S > > This wrong sequence is fixed in practice by applying the pattern: > > procedure Initialize (X : in out Derived) is > begin > Parent (X).Initialize; -- Ensure parent's initialization > > end Initialize; > > Using the pattern you get a semantically correct sequence: > > -- enter Initialize of S > -- enter Initialize of T > > -- leave Initialize of T > > -- leave Initialize of S That's the well-known Ada pattern you find in any text book. So what's your point? > But with Foo it becomes wrong again: > > + call Foo of S > Yes, because you specifically request a redispatch via the classwide pointer. You can correct this with procedure Initialize (X: in out T) is begin T (X.Self.all).Foo; -- no more Boom! end Initialize; There were some discussions in CLA about not to use dispatch in Initialize et alii. > Which is catastrophic and there is *no* way to make it right in presence > of multiple derived types. You cannot announce a call to a deferred > implementation during initialization of a specific type T. That may > happen only after initializations of all derived specific types are > complete. > > Semantically it means that it must be called in the initialization of > T'Class. The proper sequence must be: > > > > > + call Foo of S What do you mean by init of S'Class? There are no components of an S'Class. Sorry, I don't understand.