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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.31.170.200 with SMTP id t191mr1886889vke.13.1498210389148; Fri, 23 Jun 2017 02:33:09 -0700 (PDT) X-Received: by 10.157.52.232 with SMTP id t37mr181275otd.15.1498210387933; Fri, 23 Jun 2017 02:33:07 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!m54no58531qtb.1!news-out.google.com!k7ni2686itk.0!nntp.google.com!f20no115611itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 23 Jun 2017 02:33:07 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2003:c7:83c0:d49c:a560:a383:a7d:9dd8; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf NNTP-Posting-Host: 2003:c7:83c0:d49c:a560:a383:a7d:9dd8 References: <1ac5a44b-4423-443a-a7bb-2864d9abe78f@googlegroups.com> <1498048151.20885.28.camel@obry.net> <96174ea5-852d-44e9-8535-7c1eb24d5326@googlegroups.com> <98b98b8b-2f56-4d14-9989-3df51b08d97e@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <04891954-77dd-49d1-84d6-d96f3befc0b0@googlegroups.com> Subject: Re: Ada Annoyances From: AdaMagica Injection-Date: Fri, 23 Jun 2017 09:33:09 +0000 Content-Type: text/plain; charset="UTF-8" Xref: news.eternal-september.org comp.lang.ada:47070 Date: 2017-06-23T02:33:07-07:00 List-Id: Am Donnerstag, 22. Juni 2017 23:52:42 UTC+2 schrieb Dmitry A. Kazakov: > There is many ways to achieve the same [wrong] effect. E.g. without any > dispatch: > > procedure Foo (P : Parent) is > begin > Bar (Some_Descendant_Of_Parent (P)); > end Foo; > This code seems illegal to me, at least for tagged types: 1. If Foo is a primitive operation, the body cannot know the descendants. 2. The type conversion is illegal - here, an extension aggregate is needed. Niklas' example is a completely different thing. type Parent is tagged record .... end record; procedure Foo (P : Parent); -- 1 procedure Bar (P : Parent); -- 2 type Child is new Parent with record ... end record; -- Child inherits Foo from Parent. -- 1' overriding procedure Bar (C : Child); -- 3 C: Child; Foo (C); -- calls 1', i.e Foo (Parent (C)); procedure Foo (P: Parent) is begin Bar (P); -- Bar 2 Bar (Parent'Class (P)); -- Bar 3 end Foo; Whether this behaviour is wrong or not, is a different story. There are some contrived cases which only work correctly with redispatch. I do aggree that the declaration of Foo at (1) cannot show whether the body has a redispatch or not - and that's bad. It's the chore of the writer of this code that it works correctly. The user (caller) simply has to believe the writer.