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!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Ada Successor Language Date: Tue, 26 Jun 2018 19:42:45 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <5e86db65-84b9-4b5b-9aea-427a658b5ae7@googlegroups.com> <878t7u1cfm.fsf@nightsong.com> <776f3645-ed0c-4118-9b4d-21660e3bba4b@googlegroups.com> <87602fbu2g.fsf@nightsong.com> <87po0mziqt.fsf@nightsong.com> <30e271d8-0ef9-4986-8726-2b09c7fb9526@googlegroups.com> <3308847f-a440-413c-80db-6b45008778a1@googlegroups.com> NNTP-Posting-Host: 3CrKQyqWAJZHy6zYVP/kUg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 X-Notice: Filtered by postfilter v. 0.8.3 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:53337 Date: 2018-06-26T19:42:45+02:00 List-Id: On 2018-06-26 19:20, Shark8 wrote: > On Monday, June 25, 2018 at 2:20:42 AM UTC-6, Marius Amado-Alves wrote: >> This conjecture, that OO polymorphism is *always* preferrable to generics, is picking my mind big time. I've got a strong intuition that there are cases best served by generics. I'll try to find examples. Or if anyone has some please post. > > I disagree with that summation wholeheartedly; one place generics are superior to OO is in sharing code. OOP is _not_ good for that purpose, despite some claims it is. How so? The code of the bodies of inherited primitive operations and the bodies of class-wide operations are shared the in proper sense of this word. Sharing with generics is a quite difficult task if you really tried to do this. E.g. there are several approaches to specialization of shared generic code: 1. You can pass a package instance generic type T is ... package Foobar is new Foo (T => T, ... package Bar 2. You can use child generic package generic ... package Foo.Bar is None of which works satisfactory and geometrically explodes in presence of several type-parameters. An equivalent of Bar (X : A'Class; Y : B'Class; Z : C'Class); is barely possible. P.S. I have an impression that people advocating generics never really used them beyond instantiation of containers from the standard library. A real-life challenge looks like this: http://www.dmitry-kazakov.de/ada/fuzzy.htm#8 -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de