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!news2.google.com!goblin2!goblin.stu.neva.ru!news.teledata-fn.de!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 15:10:05 +0100 Message-ID: NNTP-Posting-Date: 20 Nov 2009 15:10:05 CET NNTP-Posting-Host: 8af35137.newsspool2.arcor-online.net X-Trace: DXC=SA[>ILZKPnD2:OR3:3gaE@A9EHlD;3YcB4Fo<]lROoRA8kFOFamlAWneLFB X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:8173 Date: 2009-11-20T15:10:05+01:00 List-Id: On Fri, 20 Nov 2009 14:43:45 +0100, Markus Schoepflin wrote: > So If I understand this correctly, if I want dispatching to happen on a > given type, I always need to use the class type? Exactly. This helps both the compiler to make the program much more efficient by eliminating unnecessary dispatch and you indicating the design problems like this and making it safer in the opposite cases: Consider the case where one non-abstract operation calls another: type FOO is abstract tagged null record; procedure P (THIS : in out FOO); procedure A (THIS : in out FOO); ... procedure P (THIS : in FOO) is begin ... A (THIS); -- This is a part of the implementation of P for the type FOO ... end P; Here the call to A does not dispatch. In other language like C++ it would. Now consider a type derived from FOO, that overrides A, but inherits P. That could break the implementation of P in C++, but not in Ada, where P will behave exactly as it did before. When you design P you should decide whether it is a class-wide subprogram or not. That role of P will define the behavior of calls to A from its body. Sometimes the compiler can detect that the declared role of P does not match its implementation, as it was in your case. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de