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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e9c183f3911c2d73,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.202.37 with SMTP id kf5mr2913503pbc.7.1334348079973; Fri, 13 Apr 2012 13:14:39 -0700 (PDT) Path: r9ni52693pbh.0!nntp.google.com!news1.google.com!postnews.google.com!d4g2000vbn.googlegroups.com!not-for-mail From: Katarina Olsson Newsgroups: comp.lang.ada Subject: Dynamic binding Date: Fri, 13 Apr 2012 13:13:17 -0700 (PDT) Organization: http://groups.google.com Message-ID: <32a3d08f-7b48-46e2-b8cf-004acb6e40a3@d4g2000vbn.googlegroups.com> NNTP-Posting-Host: 83.250.78.146 Mime-Version: 1.0 X-Trace: posting.google.com 1334348079 18581 127.0.0.1 (13 Apr 2012 20:14:39 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 13 Apr 2012 20:14:39 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d4g2000vbn.googlegroups.com; posting-host=83.250.78.146; posting-account=yikV-goAAACTWsgZxBw4iqS6BFfOmfrS User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; GTB7.3),gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-04-13T13:13:17-07:00 List-Id: Hello, I have a question about dispatching in Ada. As we know, methods in java are always called on their objects. Let say that we have a class Parent with methods a() and b(), where a calls b like this: class Parent{ public void a() { System.out.println("parent a"); b(); } public void b(){ System.out.println("parent b"); } } Consider now the class Child extends Parent. It has overridden the b() method like this: class Child extends Parent{ @Override public void b(){ System.out.println("child b"); } } When creating a Child object and calling the a() method, Child c = new Child(); c.a(); the output will be the following on stdout: >>parent a >>child b I have now attempted to reproduce the corresponding case in Ada. If I create a tagged record Object in package Parent, and then the corresponding procedures (or functions): procedure A (This : access all Object); procedure B (This : access all Object); and then in package Child, I create a new Parent.Object: type Object is new Parent.Object with null record ...and override the B method: overrides procedure B (This : access all Object) This should correspond to the previous java case, shouldn't it? In any case it seems to me that calling the A procedure on the Child Object, would render the output >>parent a >>parent b -- (instead of child b) Do I need to try again or have I understood it correctly? And if I have, how would I best reproduce the java behaviour?