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!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: A bad counterintuitive behaviour of Ada about OO Date: Fri, 8 Aug 2014 15:22:56 +0200 Organization: cbb software GmbH Message-ID: <2extr7bydwfw.tcda12f9xnq9.dlg@40tude.net> References: <932kntuq5rrr.8sumwibqrufn.dlg@40tude.net> <1ohy7vnbntskq$.h139ov04mlxu$.dlg@40tude.net> <536e35d6-f1de-4917-9300-26d78686eaf2@googlegroups.com> <1w3wuhu3d4nxi$.qluzbi0gtlxx$.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: pFv5JukiA5DRwd1gSNRC4g.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 8bit 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:21553 Date: 2014-08-08T15:22:56+02:00 List-Id: On Fri, 8 Aug 2014 06:06:41 -0700 (PDT), Maciej Sobczak wrote: > W dniu piątek, 8 sierpnia 2014 10:14:27 UTC+2 użytkownik Dmitry A. Kazakov napisał: > >> I still do not understand the example. > > http://en.wikipedia.org/wiki/Covariant_return_type type A is tagged null record; function getFoo return A; type B is new A with null record; overriding function getFoo return B; -- Covariant! >> Is the operation in question >> primitive for both the factory and product hierarchy? That is MD. > > I don't consider it to be an example of MD, because the two types (factory > and product) do not play equal roles in the dispatch. Namely, the > operation is expected to dispatch on the factory type only. No dispatch, no covariance. If you are in the hierarchy of the factory type, there cannot be any covariance in an unrelated hierarchy. Unless you make it MD. Even then inheriting to factory would have no effect on product. The only case where this may happen is parallel type hierarchies when two types are inherited synchronously, e.g. type Object is tagged ... type Handle is tagged ... function Access (X : Handle_To_Object) return Object; type New_Object is new Object with ... must produce type New_Handle is new Handle with ... and function Access (X : New_Handle) return New_Object; No OOPL I know can handle this. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de