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!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Finalization of library level tasks Date: Wed, 2 May 2018 16:50:10 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <3b736ddf-0807-4781-a973-6164280faae7@googlegroups.com> <894f8f3f-1713-4a75-9322-262a4eb1ecb6@googlegroups.com> NNTP-Posting-Host: MyFhHs417jM9AgzRpXn7yg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 X-Notice: Filtered by postfilter v. 0.8.3 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:51919 Date: 2018-05-02T16:50:10+02:00 List-Id: On 02/05/2018 16:34, AdaMagica wrote: > Am Dienstag, 1. Mai 2018 17:54:02 UTC+2 schrieb Niklas Holsti: >> On 18-05-01 14:18 , Jeffrey R. Carter wrote: >>> On 05/01/2018 11:17 AM, AdaMagica wrote: >>>> >>>> But he is correct on this example you gave: With redispatch, OP(X) and >>>> OP(Parent'Class(X)) are not the same. >>> >>> If you use redispatching then you get what you deserve. >> >> Which can be exactly what you want to achieve! >> >> (Obligatory dissenting voice in favour of occasional redispatching, to >> avoid the appearance that redispatching is universally abhorred.) > > Yes, there are situations where redispatching is essential. I've once come into this situation. They are all wrong, either due to design error or language problem. In particular in Ada there is no partial override. Usually re-dispatch is required because there no way to define a prologue or epilogue of a primitive operation. So if you have this: procedure Foo (X : in out T) is begin ... Do this Baz (T'Class (X)); ... Do that end Foo; That is the language problem which does not allow T to define Foo's prologue and epilogue not to be overridden: procedure Foo'Prologue (X : in out T) is begin ... Do this end Foo'Prologue; procedure Foo (X : in out T) is null; procedure Foo'Epilogue (X : in out T) is begin ... Do that end Foo'Epilogue; Then Baz would be a plain overriding of Foo, no re-dispatch. BTW, Finalize must have been an epilogue, and Initialize a prologue. > But I would say, do not use redispatch in Initialize, Adjust, Finalize. This is strong advice. Think thrice if you think you need it. It is always wrong to dispatch from Initialize and Finalize, no need to even think about it. As I said before it must be plain dispatch from class-wide Finalize/Initialize/Adjust when all type-specific Finalizes are complete and Initializes not yet called. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de