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 X-Google-Thread: a07f3367d7,366b213c4abb1039 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder.news-service.com!feeder.news-service.com!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: What makes a procedure call 'dispatching' in Ada? Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Fri, 20 Nov 2009 14:27:14 +0100 Message-ID: NNTP-Posting-Date: 20 Nov 2009 14:27:14 CET NNTP-Posting-Host: 441235de.newsspool2.arcor-online.net X-Trace: DXC=_\>:S36LcT^AX0F2i>_:>6UAj]Y5^_ X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:8166 Date: 2009-11-20T14:27:14+01:00 List-Id: On Fri, 20 Nov 2009 14:15:33 +0100, Markus Schoepflin wrote: > I'm trying to fell may way around object oriented Ada programming, and I > think I must be missing something absolutely basic. > Please consider the following package: > > ---%<--- > package FOOS is > > type FOO is abstract tagged null record; > > procedure P (THIS : in FOO); > procedure A (THIS : in FOO) is abstract; > > end FOOS; > > package body FOOS is > > procedure P (THIS : in FOO) > is > begin > A (THIS); > end; > > end FOOS; > --->%--- > > When trying to compile this, I get: > > foos.adb:6:07: call to abstract function must be dispatching > gnatmake: "foos.adb" compilation error > > What is the compiler trying to tell me here? And how do I go about calling > abstract procedures? It tells you that the type of THIS is FOO, so you cannot call to A, because A is not defined on FOO. If P is to be defined in terms of any type from the class FOO, then P has to be declared differently (class-wide): package FOOS is type FOO is abstract tagged null record; procedure P (THIS : in FOO'Class); -- I am SAME for the whole class rooted in FOO procedure A (THIS : in FOO) is abstract; -- I have an implementation in each instance of the class except -- for the abstract ones like FOO. end FOOS; package body FOOS is procedure P (THIS : in FOO'Class) is begin A (THIS); -- I do not know what kind of FOO is THIS. So I -- dispatch to A according to the tag of THIS. end P; end FOOS; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de