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 10:14:27 +0200 Organization: cbb software GmbH Message-ID: <1w3wuhu3d4nxi$.qluzbi0gtlxx$.dlg@40tude.net> References: <932kntuq5rrr.8sumwibqrufn.dlg@40tude.net> <1ohy7vnbntskq$.h139ov04mlxu$.dlg@40tude.net> <536e35d6-f1de-4917-9300-26d78686eaf2@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: ot/DC7n2aCvt5pcTM4dZCw.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:21535 Date: 2014-08-08T10:14:27+02:00 List-Id: On Fri, 8 Aug 2014 00:54:01 -0700 (PDT), Maciej Sobczak wrote: > W dniu czwartek, 7 sierpnia 2014 10:50:52 UTC+2 użytkownik Dmitry A. Kazakov napisał: > >>> and no support for type covariance on return >>> type Ada is way more broken than other languages I am aware of. >> >> I don't understand this. The return type is covariant in Ada. > > Can I have Better_Factory type with a primitive operation returning Better_Product? I still do not understand the example. Is the operation in question primitive for both the factory and product hierarchy? That is MD. > No, because Better_Product is a different type than Product and such > operation would not be considered overriding. Different how? Unrelated, derived from? ------------------ Covariance means that upon inheritance the argument or result of an operation mutates to the derived type. All primitive operations in Ada are covariant per definition. The only way to have an operation contravariant is to declare it after the freezing point (in another package) or having the argument/result class-wide => non-primitive. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de