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 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!news.glorb.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!fx20.iad.POSTED!not-for-mail From: Shark8 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:30.0) Gecko/20100101 Thunderbird/30.0a1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: A bad counterintuitive behaviour of Ada about OO References: <932kntuq5rrr.8sumwibqrufn.dlg@40tude.net> <1ohy7vnbntskq$.h139ov04mlxu$.dlg@40tude.net> <536e35d6-f1de-4917-9300-26d78686eaf2@googlegroups.com> In-Reply-To: <536e35d6-f1de-4917-9300-26d78686eaf2@googlegroups.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Message-ID: X-Complaints-To: abuse@teranews.com NNTP-Posting-Date: Fri, 08 Aug 2014 08:34:45 UTC Organization: TeraNews.com Date: Fri, 08 Aug 2014 02:34:43 -0600 X-Received-Bytes: 2342 X-Received-Body-CRC: 2810857101 Xref: news.eternal-september.org comp.lang.ada:21538 Date: 2014-08-08T02:34:43-06:00 List-Id: On 08-Aug-14 01:54, 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? > > No, because Better_Product is a different type than Product and such operation > would not be considered overriding. This works properly in just about any other > language with support for OO. > Can't you use some class-wide functions, some primitive functions, and the Generic_Dispatching_Constructor function to do this? IIRC something like: Type Base is abstract tagged null record; Function Product return Base is abstract; -- Primitive function. Function Get_Product return Base'Class; -- Dispatches call to Product. -- Uses generic_dispatching constructor. Function Make(Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Base'Class; -- For Stream-creation. -- Perhaps some other creation functions. -- ... Type Child is tagged ... Or am I misunderstanding you?