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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: I'm facing an issue with: call to abstract procedure must be dispatching Date: Tue, 8 Dec 2015 19:22:20 +0100 Organization: cbb software GmbH Message-ID: References: <8bc7fd76-f00a-4eea-9715-470af028fc84@googlegroups.com> <1krm4xun4e4ny.jmh9kvf6s0a9.dlg@40tude.net> <12dc7aea-933d-4271-95bd-10df808917e4@googlegroups.com> <5hfb2q9imjfu.zs3xp9gxw0d3.dlg@40tude.net> <5788b259-8886-4ee2-8c3d-7799abfd840e@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: Sfz0eNwKWh4Uq03iti+GMw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:28715 Date: 2015-12-08T19:22:20+01:00 List-Id: On Tue, 8 Dec 2015 10:00:24 -0800 (PST), Serge Robyns wrote: > On Tuesday, 8 December 2015 18:42:26 UTC+1, Dmitry A. Kazakov wrote: >> On Tue, 8 Dec 2015 09:24:58 -0800 (PST), Serge Robyns wrote: >> In which relation is Do_Something to T_Abstract_Store? >> >> 1. a primitive operation = >> has a separate implementation for each concrete type (from the class) >> 2. class-wide operation = >> has same implementation for all types (from the class) >> >> (anything else is a design fault) >> >>> Inside that procedure I'm using the A_Store. This regardless how A_Store >>> got implemented. >> >> That sounds like #2. Then it must be declared as: > > This is indeed Correct. Thanks for the tip. Now it works, well at least it compiles ..... > > procedure test is > > type T_Store is new T_Asbtract_Store with null record; > > overriding procedure Insert (Store : in out T_Store; > Client : in T_Client'Class) is > begin > null; > end Insert; > > procedure Do_Something (A_Store : in out T_Asbtract_Store'Class) > is > Client : T_Client; > begin > A_Store.Insert (Client); > end Do_Something; > > A_Store : access T_Asbtract_Store; Observe that exactly same logic applies here. You never ever use a type-specific access type when you deal with whole class. Thus, without any further considerations it must be this: A_Store : access T_Asbtract_Store'Class; In each instance you should clearly understand whether the code deals with one specific type or with all class. Once you know that, you express this knowledge in terms of types. One of the major Ada advantages with respect to OO is that it is properly typed. The type of a specific instance and the type of all instances from the class are two *different* types. The language rejected your program not because of being cruel, but because you used one type as if it were another. > The_Store : aliased T_Store; > > begin > A_Store := T_Asbtract_Store (The_Store)'Access; Now, of course no explicit type conversion required: A_Store := The_Store'Access; (Type conversion must raise alarm bells) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de