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 autolearn=unavailable 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!nntp-feed.chiark.greenend.org.uk!ewrotcd!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: A bad counterintuitive behaviour of Ada about OO Date: Fri, 8 Aug 2014 17:32:23 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <932kntuq5rrr.8sumwibqrufn.dlg@40tude.net> <1ohy7vnbntskq$.h139ov04mlxu$.dlg@40tude.net> <536e35d6-f1de-4917-9300-26d78686eaf2@googlegroups.com> <1w3wuhu3d4nxi$.qluzbi0gtlxx$.dlg@40tude.net> <2extr7bydwfw.tcda12f9xnq9.dlg@40tude.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: loke.gir.dk 1407537144 4665 69.95.181.76 (8 Aug 2014 22:32:24 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 8 Aug 2014 22:32:24 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:21592 Date: 2014-08-08T17:32:23-05:00 List-Id: "Dmitry A. Kazakov" wrote in message news:2extr7bydwfw.tcda12f9xnq9.dlg@40tude.net... ... > 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. I've toyed with proposing this for Ada (seriously). The containers in particular are tagged but cannot be usefully extended because of this problem. It's unclear, though, that the model would actually work. In any case, this is the only way to do covariance of unrelated types. Otherwise, you're just in the realm of overloading (usually a better solution anyway, IMHO). Randy.