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: Wed, 20 Jun 2018 09:59:55 +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> <87fu1izfgs.fsf@nightsong.com> NNTP-Posting-Host: MyFhHs417jM9AgzRpXn7yg.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:53190 Date: 2018-06-20T09:59:55+02:00 List-Id: On 2018-06-19 22:30, Paul Rubin wrote: > "Dmitry A. Kazakov" writes: >> Generics and macros are same thing regardless implementation. > > I don't understand what the issue is. 1. Generics is a second-order language. We don't need yet another language unless strong reasons shown. [ This how Stepanov's advocacy goes. He tries to show that generic programming requires generics. My point is that maybe not. ] 2. Generics are static. There is no class-wide instances of generic classes. E.g. taking the generic class "(<>) is private" as in type T is (<>) is private; There is no way to declare: X : (<>) is private'Class := ; This has very concrete consequences. For example, declare dimensioned measurement unit types in a generic and then try to write a calculator dealing with units. No way. 3. Once generic, always generic. 4. No proper reuse. Generic bodies are no proper compilation units, you cannot have a shared library of generics. Therefore the only possible form of reuse is textual substitution and recompilation of the client code. 5. No proper separation of interface and implementation. If you used Ada generics you would know that successful compilation of a generic body means little. Instantiation can always fail even if all formal parameters match. The compiler must look into the body not just for the sake of optimization and representation, but for validity of instantiation, just like in C++. A macro is a macro. > I don't think it was a mistake > for C++ to have generics since the generic approach in C++ is IME much > better than the OO approach with inheritance. This is evidently wrong. Ada programs extensively using generics are as impossible to maintain as C++ programs using templates. IMO generics have no place in SW engineering. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de